define([
    "UtilDir/util",
    "UtilDir/tool",
    "UtilDir/org/selectOrg",
    "UtilDir/searchBlock",
    "static/app/hddc/hddccjcommon/hddccjCommon",
    "static/app/hddc/hddcShpDataMapDisplay/hddcPointData",
    "UtilDir/loading",
    "static/app/hddc/hddcShpDataMapDisplay/hddcshpdata",
    "Date","DateCN", "css!DateCss",
    "EasyUI","EasyUI-lang"
],function(Util, Tool, SelectOrg, SearchBlock,HddccjCommon,hddcPointData,Loading){

    var getHddcCjTaskController = function(){
        return getServer() + "/hddc/hddcCjTasks";
    };
    var map=null;
    var lay1=null;
    var lay2=null;
    var lay3 =null;
    var lay4 =null;
    var lay5 =null;
    var lay6 =null;
    var lay7 =null;
    var replayDataInterval = null;

    var userauth=null;

    function initMap() {
        if (map != null) {
        } else {
            //初始化地图对象

            /*
            var imageURL = "http://t0.tianditu.gov.cn/img_w/wmts?" +
                "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
                "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=acce9f1241bb60d5164939ee53173caf";
             */
            //天地图矢量
            var imageURL1="https://fxpc.mem.gov.cn/data_preparation/171dd1d5-bbb3-483a-a7f6-50d6d98cee1f/d9ffc071-50dd-4780-a617-673d17921e22/wmts?service=wmts&request=gettile&version=1.0.0&layer=vec&style=default&tilematrixset=c&format=tiles&tilematrix={z}&tilerow={y}&tilecol={x}&geokey=94E99EB4FEB9B48CD5348F7BCF5BB620";
            lay1 = new T.TileLayer(imageURL1, {minZoom: 1, maxZoom: 18});
            //天地图矢量注记
            var imageURL2="https://fxpc.mem.gov.cn/data_preparation/171dd1d5-bbb3-483a-a7f6-50d6d98cee1f/13f8b69d-98dc-4276-bbf0-9c4c372acabc/wmts?service=wmts&request=gettile&version=1.0.0&layer=cva&style=default&tilematrixset=c&format=tiles&tilematrix={z}&tilerow={y}&tilecol={x}&geokey=94E99EB4FEB9B48CD5348F7BCF5BB620";
            lay2 = new T.TileLayer(imageURL2, {minZoom: 1, maxZoom: 18});
            //天地图影像
            var imageURL3="https://fxpc.mem.gov.cn/data_preparation/171dd1d5-bbb3-483a-a7f6-50d6d98cee1f/16646cf6-305e-45b3-9be9-81f7dfc9813f/wmts?service=wmts&request=gettile&version=1.0.0&layer=img&style=default&tilematrixset=c&format=tiles&tilematrix={z}&tilerow={y}&tilecol={x}&geokey=94E99EB4FEB9B48CD5348F7BCF5BB620";
            lay3 = new T.TileLayer(imageURL3, {minZoom: 1, maxZoom: 18});
            //天地图影像注记
            var imageURL4="https://fxpc.mem.gov.cn/data_preparation/171dd1d5-bbb3-483a-a7f6-50d6d98cee1f/0f7d6202-bdad-4cc7-a3b1-e86ec950f35d/wmts?service=wmts&request=gettile&version=1.0.0&layer=cia&style=default&tilematrixset=c&format=tiles&tilematrix={z}&tilerow={y}&tilecol={x}&geokey=94E99EB4FEB9B48CD5348F7BCF5BB620";
            lay4 = new T.TileLayer(imageURL4, {minZoom: 1, maxZoom: 18});
            //天地图地形
            var imageURL5="https://fxpc.mem.gov.cn/data_preparation/171dd1d5-bbb3-483a-a7f6-50d6d98cee1f/9a10d9a2-e2be-45bb-8ddc-4fa3004022e4/wmts?service=wmts&request=gettile&version=1.0.0&layer=ter&style=default&tilematrixset=c&format=tiles&tilematrix={z}&tilerow={y}&tilecol={x}&geokey=94E99EB4FEB9B48CD5348F7BCF5BB620";
            lay5 = new T.TileLayer(imageURL5, {minZoom: 1, maxZoom: 18});
            //天地图地形注记
            var imageURL6="https://fxpc.mem.gov.cn/data_preparation/171dd1d5-bbb3-483a-a7f6-50d6d98cee1f/2f817c65-a621-48d7-91d7-fb4fd12657a8/wmts?service=wmts&request=gettile&version=1.0.0&layer=cat&style=default&tilematrixset=c&format=tiles&tilematrix={z}&tilerow={y}&tilecol={x}&geokey=94E99EB4FEB9B48CD5348F7BCF5BB620";
            lay6 = new T.TileLayer(imageURL6, {minZoom: 1, maxZoom: 18});
            //0.8米影像
            var imageURL7="https://fxpc.mem.gov.cn/data_preparation/171dd1d5-bbb3-483a-a7f6-50d6d98cee1f/4d481300-7a88-4b5b-9bb7-424ff6a5abea/wmts?service=WMTS&request=GetTile&version=1.0.0&layer=img08&style=default&tilematrixset=c&format=tiles&tilematrix={z}&tilerow={y}&tilecol={x}&geokey=94E99EB4FEB9B48CD5348F7BCF5BB620";
            lay7 = new T.TileLayer(imageURL7, {minZoom: 1, maxZoom: 18});
            var config = {
                projection: "EPSG:4326",
                minZoom: 4,
                layers: [lay1, lay2]
            };
            //https://fxpc.mem.gov.cn/wmts?service=wmts&request=gettile&version=1.0.0&layer=cva&style=default&tilematrixset=c&format=tiles&tilematrix=9&tilerow=75&tilecol=423
            map = new T.Map("hddctask-map", config);
            map.clearOverLays();
            //设置显示地图的中心点和级别
            map.centerAndZoom(new T.LngLat(116.40969, 39.89945), 4);

            var control = new T.Control.Zoom();
            map.addControl(control);

            //创建比例尺控件对象
            var scale = new T.Control.Scale();
            //scale.setOptions()
            map.addControl(scale);

            map.enableScrollWheelZoom();
            map.enableDrag();

            /*
            //创建鹰眼控件对象
            var miniMap = new T.Control.OverviewMap({
                 isOpen: true,
                 size: new T.Point(150, 150)
             });
             map.addControl(miniMap);

             */

            var bodyWidth = window.innerWidth - 15;//1920px
            var mapHeight = window.innerHeight - 40;//796px
            var mapWidth = bodyWidth;//1469px

            $("#hddctask-mapDiv").css("height", mapHeight + "px");
            $("#hddctask-mapDiv").css("width", mapWidth + "px");
            $("#hddctask-map").css("height", mapHeight + "px");
            $("#hddctask-map").css("width", mapWidth + "px");

            map.checkResize();

            //$("#maptype_displaybutton").css("z-index", "1100");
            //$("#maptype_displaybutton").show();

            $("#spacelayer-setDivPosition").css("z-index", "1100");
            $("#spacelayer-setDivPosition").show();



        }
        map.clearOverLays();

        initUserAuth();

        //initMapInterface();
        initMapHitEvent();
        initTaskToolsEvent();
        initcreateProvince();
        initcreateProvince1();
        //initData(data);

        //测试
        //console.log("test0");

        //查询并添加全部数据到地图上
        initQueryAddAllData();
        /*setTimeout(function(){
            //查询并添加全部数据到地图上
            initQueryAddAllData();
        },1000);*/
    };

    //allhpdatainfolines
    var layerSelectBoolline=false;
    var moveHitArea=false;
    var singleSearchType=false;
    function initMapHitEvent() {
        map.addEventListener("click",function(e){
            //隐藏右键菜单
            if ($("#imgfangda-DisplayDiv").attr("src") == "/hdc/static/app/hddc/hddccjtask/images/qxfangda.png") {
                $("#imgfangda-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/fangda.png");
                var lnglat = e.lnglat;
                map.centerAndZoom(lnglat, 10);
            }
        });

        map.addEventListener("mousemove",function(e){//是否应该用click方法 mousemove
            //判断点到线或者到面的距离
            //应该计算的是像素距离，不是地理距离
            moveHitArea=false;
            var distance=getMenuDistance();
            for(var i=0;i<allhpdatainfolines.length;i++){
                if(moveHitArea){
                    break;
                }
                var data=allhpdatainfolines[i];
                var display = layerShowHideBoolArray[data.type];
                if(display||singleSearchType){
                    var lnglat = e.lnglat;
                    var p = map.lngLatToContainerPoint(lnglat);
                    var points=data.geodatas.getLngLats();
                    if(points!=null) {
                        for (var j = 0; j < points.length-1; j++) {
                            var pp1=map.lngLatToContainerPoint(points[j]);
                            var pp2=map.lngLatToContainerPoint(points[j+1]);
                            //var dd=p.distanceTo(pp);
                            var dd=getPointToLineDistance(p,pp1,pp2);
                            if(dd<distance){
                                $(".tdt-grab").css("cursor",  "pointer");
                                moveHitArea=true;
                                break;
                            }else{
                                $(".tdt-grab").css("cursor",  "-webkit-grab");
                            }
                        }
                    }
                }
            }
        });

        map.addEventListener("contextmenu",function(e){//是否应该用click方法 mousemove
            //判断点到线或者到面的距离
            //应该计算的是像素距离，不是地理距离
            var distance=100;
            var phit=null;
            var selectshpdata=null;
            for(var i=0;i<allhpdatainfolines.length;i++){
                var data=allhpdatainfolines[i];
                var display = layerShowHideBoolArray[data.type];
                if(display||singleSearchType){
                    var lnglat = e.lnglat;
                    var p = map.lngLatToContainerPoint(lnglat);
                    var points=data.geodatas.getLngLats();
                    if(points!=null) {
                        for (var j = 0; j < points.length-1; j++) {
                            var pp1=map.lngLatToContainerPoint(points[j]);
                            var pp2=map.lngLatToContainerPoint(points[j+1]);
                            //var dd=p.distanceTo(pp);
                            var dd=getPointToLineDistance(p,pp1,pp2);
                            if(dd<distance){
                                distance=dd;
                                phit=p;
                                selectshpdata=data;
                            }
                        }
                    }
                }
            }
            if(distance<getMenuDistance() && selectshpdata!=null&&phit!=null){
                layerSelectType = selectshpdata.type;//选中的图层类型
                layerSelectUuid = selectshpdata.id;//选中的图层数据UUID
                layerSelectBoolline = true;//是否选中图层数据
            }else{
                //$("#layerContextMenuDiv").hide();
                layerSelectBoolline = false;
            }
        });
    }

    function getMenuDistance(){
        var distance=30;
        var zoom = map.getZoom();
        if(zoom>=10){
            distance=30;
        }else if(zoom>=6&&zoom<10){
            distance=20;
        }else if(zoom<6){
            distance=10;
        }
        return distance;
    }

    function getPointToLineDistance(hitpoint,pointstart,pointend) {
        if(pointstart.x==pointend.x && pointstart.y==pointend.y){
            return hitpoint.distanceTo(pointstart);
        }
        var dp1=dotProduct(calcPoints(pointend,pointstart),calcPoints(pointend,hitpoint));
        if(dp1<=0){
            return hitpoint.distanceTo(pointend);
        }
        var dp2=dotProduct(calcPoints(pointstart,pointend),calcPoints(pointstart,hitpoint));
        if(dp2<=0){
            return hitpoint.distanceTo(pointstart);
        }
        var signedDistance=crossProduct(pointstart,pointend,hitpoint)/pointstart.distanceTo(pointend);
        return Math.abs(signedDistance);
    }

    function crossProduct(pointstart,pointend,hitpoint){//面积
        var p1=calcPoints(pointstart,pointend);
        var p2=calcPoints(pointstart,hitpoint);
        return p1[0]*p2[1]-p2[0]*p1[1];
    }

    function dotProduct(point1,point2){
       return point1[0]*point2[0]+point1[1]*point2[1];
    }

    function calcPoints(start,end){
        var point=[];
        point[0]=end.x-start.x;
        point[1]=end.y-start.y;
        return point;
    }

    function initUserAuth(){
        $.ajax({
            url: getServer() + "/hddc/user/auth",
            contentType: "application/json",
            type: "get",
            success: function (data) {
                userauth=data;
            }
        });
    }

    var initcreateProvince = function () {
        var html = "";
        $("#citySelect").append(html);
        $("#areaSelect").append(html);
        $.ajax({
            url: getServer() + "/divisions/root/subdivisions",
            contentType: "application/json",
            type: "get",
            success: function (data) {
                $.each(data, function (idx, item) {
                    html += "<option value='" + item.divisionCode + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                });
                $("#provinceSelect").append(html);
            }
        });
        $("#provinceSelect").change(function () {
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#citySelect option").remove();
            $("#citySelect").append(html);
            $("#areaSelect option").remove();
            $("#areaSelect").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            // if ($(this).val() == "110000" || $(this).val() == "120000" || $(this).val() == "310000" || $(this).val() == "500000") {
            //     $("#citySelect").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + $(this).val() + "</option>");
            //     return;
            // }
            if($(this).val() == "110000"){
                $("#citySelect").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + "北京市" + "</option>");
                return;
            }else if($(this).val() == "120000"){
                $("#citySelect").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + "天津市" + "</option>");
                return;
            }else if($(this).val() == "310000"){
                $("#citySelect").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + "上海市" + "</option>");
                return;
            }else if($(this).val() == "500000"){
                $("#citySelect").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + "重庆市" + "</option>");
                return;
            }
            $.ajax({
                url: getServer() + "/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionCode + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#citySelect").append(html);
                }
            });
        });
        $("#citySelect").change(function () {
            if ($(this).val() == "") return;
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#areaSelect option").remove();
            $("#areaSelect").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            $.ajax({
                url: getServer() + "/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionCode + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#areaSelect").append(html);
                }
            });
        });
    };

    var initcreateProvince1 = function () {
        var html = "";
        $("#citySelect1").append(html);
        $("#areaSelect1").append(html);
        $.ajax({
            url: getServer() + "/divisions/root/subdivisions",
            contentType: "application/json",
            type: "get",
            success: function (data) {
                $.each(data, function (idx, item) {
                    html += "<option value='" + item.divisionCode + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                });
                $("#provinceSelect1").append(html);
            }
        });
        $("#provinceSelect1").change(function () {
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#citySelect1 option").remove();
            $("#citySelect1").append(html);
            $("#areaSelect1 option").remove();
            $("#areaSelect1").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            // if ($(this).val() == "110000" || $(this).val() == "120000" || $(this).val() == "310000" || $(this).val() == "500000") {
            //     $("#citySelect").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + $(this).val() + "</option>");
            //     return;
            // }
            if($(this).val() == "110000"){
                $("#citySelect1").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + "北京市" + "</option>");
                return;
            }else if($(this).val() == "120000"){
                $("#citySelect1").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + "天津市" + "</option>");
                return;
            }else if($(this).val() == "310000"){
                $("#citySelect1").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + "上海市" + "</option>");
                return;
            }else if($(this).val() == "500000"){
                $("#citySelect1").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + "重庆市" + "</option>");
                return;
            }
            $.ajax({
                url: getServer() + "/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionCode + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#citySelect1").append(html);
                }
            });
        });
        $("#citySelect1").change(function () {
            if ($(this).val() == "") return;
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#areaSelect1 option").remove();
            $("#areaSelect1").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            $.ajax({
                url: getServer() + "/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionCode + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#areaSelect1").append(html);
                }
            });
        });
    };


    function initClearMap(){
        if(replayDataInterval!=null){
            clearInterval(replayDataInterval);
            replayDataInterval=null;
        }
        map.clearOverLays();
    }

    var hitIndex=0;
    function initTaskToolsEvent(){
        $("#imgoperate-DisplayDivSelect").unbind("click");
        $("#imgoperate-DisplayDivSelect").click(function () {
            $("#imgfangda-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/fangda.png");
            if ($("#imgoperate-DisplayDivSelect").attr("src") == "/hdc/static/app/hddc/hddccjtask/images/maptype0.png"){
                $("#imgoperate-DisplayDivSelect").attr("src", "/hdc/static/app/hddc/hddccjtask/images/maptype1.png");
                $("#maptype-maptypeDisplayDiv").css("display", "block");
            }else{
                $("#imgoperate-DisplayDivSelect").attr("src", "/hdc/static/app/hddc/hddccjtask/images/maptype0.png");
                $("#maptype-maptypeDisplayDiv").css("display", "none");
            }
            $("#maptype-maptypeDisplayDiv").css("z-index", "1100");

            /*if(hitIndex==0){
                $("#maptype-maptypeDisplayDiv").css("display", "block");
                //$("#maptype-maptypeDisplayDiv").css("color", "black");
                hitIndex=1;
            }else{
                $("#maptype-maptypeDisplayDiv").css("display", "none");
                //$("#maptype-maptypeDisplayDiv").css("color", "3B49EE");
                hitIndex=0;
            }*/
        });
        $("#maptype1-DisplayImage").unbind("click");
        $("#maptype1-DisplayImage").click(function () {
            $("#imgfangda-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/fangda.png");
            hitIndex=0;
            map.removeLayer(lay3);
            map.removeLayer(lay4);
            map.removeLayer(lay5);
            map.removeLayer(lay6);
            map.removeLayer(lay7);
            $("#maptype-maptypeDisplayDiv").css("display", "none");
            $("#imgoperate-DisplayDivSelect").attr("src", "/hdc/static/app/hddc/hddccjtask/images/maptype0.png");
        });
        $("#maptype2-DisplayImage").unbind("click");
        $("#maptype2-DisplayImage").click(function () {
            $("#imgfangda-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/fangda.png");
            hitIndex=0;
            map.removeLayer(lay5);
            map.removeLayer(lay6);
            map.removeLayer(lay7);
            map.addLayer(lay3);
            map.addLayer(lay4);
            $("#maptype-maptypeDisplayDiv").css("display", "none");
            $("#imgoperate-DisplayDivSelect").attr("src", "/hdc/static/app/hddc/hddccjtask/images/maptype0.png");
        });
        $("#maptype3-DisplayImage").unbind("click");
        $("#maptype3-DisplayImage").click(function () {
            $("#imgfangda-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/fangda.png");
            hitIndex=0;
            map.removeLayer(lay3);
            map.removeLayer(lay4);
            map.removeLayer(lay7);
            map.addLayer(lay5);
            map.addLayer(lay6);
            $("#maptype-maptypeDisplayDiv").css("display", "none");
            $("#imgoperate-DisplayDivSelect").attr("src", "/hdc/static/app/hddc/hddccjtask/images/maptype0.png");
        });
        $("#maptype4-DisplayImage").unbind("click");
        $("#maptype4-DisplayImage").click(function () {
            $("#imgfangda-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/fangda.png");
            hitIndex=0;
            map.removeLayer(lay3);
            map.removeLayer(lay4);
            map.removeLayer(lay5);
            map.removeLayer(lay6);
            map.addLayer(lay7);
            $("#maptype-maptypeDisplayDiv").css("display", "none");
            $("#imgoperate-DisplayDivSelect").attr("src", "/hdc/static/app/hddc/hddccjtask/images/maptype0.png");
        });


        $("#imgspacelayer-DisplayDiv").unbind("click");
        $("#imgspacelayer-DisplayDiv").click(function () {
            $("#imgfangda-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/fangda.png");
            $("#imgoperate-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/gongjuxiangoff.png");
            $("#imgoperate-DisplayDiv1").attr("src", "/hdc/static/app/hddc/hddccjtask/images/guanlioff.png");
            $("#maptype-dataoperate").css("display", "none");
            $("#maptype-dataoperate1").css("display", "none");
            $("#provinceSelect").val("");
            $("#citySelect").val("");
            $("#areaSelect").val("");
            $("#selectdDtaType").val("");
            $("#commentInfo").val("");
            hitIndex=0;
            if(singleSearchType) {
                displayAllsearchshpdata(false);
                singleSearchType=false;
            }
            $("#searchresultDiv").hide();

            if ($("#imgspacelayer-DisplayDiv").attr("src") == "/hdc/static/app/hddc/hddccjtask/images/tucengon.png") {
                $("#imgspacelayer-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/tucengoff.png");
                //layerCheckBoxControlShowBool = false;
                firstLayerCheckBoxControl.hide();//隐藏控件
                if(secondLayerCheckBoxControl!=null){
                    //移除控件
                    map.removeControl(secondLayerCheckBoxControl);
                    secondLayerCheckBoxControl = null;
                }
            }else{
                $("#imgspacelayer-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/tucengon.png");
                firstLayerCheckBoxControl.show();//显示控件
            }
        });

        $("#button-closeForm").unbind("click");
        $("#button-closeForm").click(function () {
             $("#maptype-dataoperate").css("display", "none");
            $("#imgoperate-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/gongjuxiangoff.png");
            $("#imgoperate-DisplayDiv1").attr("src", "/hdc/static/app/hddc/hddccjtask/images/guanlioff.png");
             //$("#maptype-maptypeDisplayDiv").css("color", "3B49EE");
            // 清除数据
            $("#provinceSelect").val("");
            $("#citySelect").val("");
            $("#areaSelect").val("");
            $("#selectdDtaType").val("");
            $("#commentInfo").val("");
             hitIndex=0;
        });
        $("#button-closeForm1").unbind("click");
        $("#button-closeForm1").click(function () {
            $("#maptype-dataoperate1").css("display", "none");
            //$("#imgoperate-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/gongjuxiangoff.png");
            $("#imgoperate-DisplayDiv1").attr("src", "/hdc/static/app/hddc/hddccjtask/images/guanlioff.png");
            //$("#maptype-maptypeDisplayDiv").css("color", "3B49EE");
            // 清除数据
            $("#provinceSelect1").val("");
            $("#citySelect1").val("");
            $("#areaSelect1").val("");
            $("#selectdDtaType1").val("");
            hitIndex=0;
        });
        $("#imgoperate-DisplayDiv").unbind("click");
        $("#imgoperate-DisplayDiv").click(function () {
            $("#imgfangda-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/fangda.png");
            $("#imgspacelayer-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/tucengoff.png");
            $("#imgoperate-DisplayDiv1").attr("src", "/hdc/static/app/hddc/hddccjtask/images/guanlioff.png");
            firstLayerCheckBoxControl.hide();//隐藏控件
            $("#maptype-dataoperate1").css("display", "none");
            if(secondLayerCheckBoxControl!=null){
                //移除控件
                map.removeControl(secondLayerCheckBoxControl);
                secondLayerCheckBoxControl = null;
            }
            $("#maptype-dataoperate").css("z-index", "1100");

            if ($("#imgoperate-DisplayDiv").attr("src") == "/hdc/static/app/hddc/hddccjtask/images/gongjuxiangon.png") {
                $("#imgoperate-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/gongjuxiangoff.png");
                $("#maptype-dataoperate").css("display", "none");
            }else{
                $("#imgoperate-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/gongjuxiangon.png");
                $("#maptype-dataoperate").css("display", "block");
            }
        });

        $("#imgoperate-DisplayDiv1").unbind("click");
        $("#imgoperate-DisplayDiv1").click(function () {
            $("#imgfangda-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/fangda.png");
            $("#imgoperate-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/gongjuxiangoff.png");
            $("#imgspacelayer-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/tucengoff.png");
            firstLayerCheckBoxControl.hide();//隐藏控件
            $("#maptype-dataoperate").css("display", "none");
            if(secondLayerCheckBoxControl!=null){
                //移除控件
                map.removeControl(secondLayerCheckBoxControl);
                secondLayerCheckBoxControl = null;
            }
            $("#maptype-dataoperate1").css("z-index", "1100");

            if ($("#imgoperate-DisplayDiv1").attr("src") == "/hdc/static/app/hddc/hddccjtask/images/guanlion.png") {
                $("#imgoperate-DisplayDiv1").attr("src", "/hdc/static/app/hddc/hddccjtask/images/guanlioff.png");
                $("#maptype-dataoperate1").css("display", "none");
            }else{
                $("#imgoperate-DisplayDiv1").attr("src", "/hdc/static/app/hddc/hddccjtask/images/guanlion.png");
                $("#maptype-dataoperate1").css("display", "block");
            }
        });
        $("#imgfangda-DisplayDiv").unbind("click");
        $("#imgfangda-DisplayDiv").click(function () {
            $("#imgoperate-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/gongjuxiangoff.png");
            $("#imgspacelayer-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/tucengoff.png");
            $("#imgoperate-DisplayDiv1").attr("src", "/hdc/static/app/hddc/hddccjtask/images/guanlioff.png");
            $("#maptype-dataoperate1").css("display", "none");
            firstLayerCheckBoxControl.hide();//隐藏控件
            $("#maptype-dataoperate").css("display", "none");
            if(secondLayerCheckBoxControl!=null){
                //移除控件
                map.removeControl(secondLayerCheckBoxControl);
                secondLayerCheckBoxControl = null;
            }
            $("#maptype-dataoperate1").css("z-index", "1100");

            if ($("#imgfangda-DisplayDiv").attr("src") == "/hdc/static/app/hddc/hddccjtask/images/fangda.png") {
                $("#imgfangda-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/qxfangda.png");
            }else{
                $("#imgfangda-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/fangda.png");
            }
        });


       /* $("#button-maptypeDisplayDiv").unbind("click");
        $("#button-maptypeDisplayDiv").click(function () {
            $("#imgspacelayer-DisplayDiv").attr("src", "/hdc/static/app/hddc/hddccjtask/images/tucengoff.png");
            firstLayerCheckBoxControl.hide();//隐藏控件
            if(secondLayerCheckBoxControl!=null){
                //移除控件
                map.removeControl(secondLayerCheckBoxControl);
                secondLayerCheckBoxControl = null;
            }
            $("#maptype-dataoperate").css("z-index", "1100");
            if(hitIndex==0){
                $("#maptype-dataoperate").css("display", "block");
                //$("#maptype-maptypeDisplayDiv").css("color", "black");
                hitIndex=1;
            }else{
                $("#maptype-dataoperate").css("display", "none");
                //$("#maptype-maptypeDisplayDiv").css("color", "3B49EE");
                hitIndex=0;
            }

        });*/
        $("#button-search").unbind("click");
        $("#button-search").click(function () {
            searchshpdatainfos=[];
            searchshpdatainfos.length=0;
            displayshpdatainfos=[];
            displayshpdatainfos.length=0;
            fileshpinfos=[];
            fileshpinfos.length=0;
            $("#searchresultDiv").hide();
            var province=$("#provinceSelect1 option:checked").text();
            if(province=="请选择"){
                province=null;
            }
            var city=$("#citySelect1 option:checked").text();
            if(city=="请选择"){
                city=null;
            }
            var area=$("#areaSelect1 option:checked").text();
            if(area=="请选择"){
                area=null;
            }
            var type=$("#selectdDtaType1").val();
            //var type=2;
            if(type==""||type==null){
                Util.alert("数据类型必须选择");
                return;
            }
            type=parseInt(type);
            /*var isloadtype=false;
            for(var i=0;i<loadmaptypes.length;i++){
                if(type==loadmaptypes[i]){
                    isloadtype=true;
                    break;
                }
            }
            /!*if(loadmaptypes.indexOf(type)>=0){
                isloadtype=true;
            }*!/
            if(!isloadtype) {
                showHideLayerByTypeBool(type, true);
            }*/

            if(loadmaptypes.indexOf(type)<0){
                showHideLayerByTypeBool(type, true);
                var interval = setInterval(function(){
                    if(loadmaptypes.indexOf(type)>=0){
                        clearInterval(interval);
                        searchResultData(province,city,area,type);
                        showHideLayerByTypeBool(type,false);
                    }
                },1000);
            }else{
                searchResultData(province,city,area,type);
                showHideLayerByTypeBool(type,false);
            }

            singleSearchType=true;

        });
        $("#button-searchcloseForm").unbind("click");
        $("#button-searchcloseForm").click(function () {
            $("#searchresultDiv").hide();

        });
        /*$("#maptype1-DisplayImage").unbind("click");
        $("#maptype1-DisplayImage").click(function () {
            hitIndex=0;
            map.removeLayer(lay3);
            map.removeLayer(lay4);
            map.removeLayer(lay5);
            map.removeLayer(lay6);
            $("#maptype-maptypeDisplayDiv").css("display", "none");
        });
        $("#maptype2-DisplayImage").unbind("click");
        $("#maptype2-DisplayImage").click(function () {
            hitIndex=0;
            map.removeLayer(lay5);
            map.removeLayer(lay6);
            map.addLayer(lay3);
            map.addLayer(lay4);
            $("#maptype-maptypeDisplayDiv").css("display", "none");
        });
        $("#maptype3-DisplayImage").unbind("click");
        $("#maptype3-DisplayImage").click(function () {
            hitIndex=0;
            map.removeLayer(lay3);
            map.removeLayer(lay4);
            map.addLayer(lay5);
            map.addLayer(lay6);
            $("#maptype-maptypeDisplayDiv").css("display", "none");
        });*/
    }

    var allloadmapdatas=[];//加载到地图上的数据类型集合
    var searchResultData = function(province,city,area,type){
        for(var i=0;i<allshpdatainfos.length;i++){
            var shpdata=allshpdatainfos[i];
            if(type!=shpdata.type){
                continue;
            }

            if(area!=null&&area!=shpdata.area){
                continue;
            }
            if(city!=null&&city!=shpdata.city){
                continue;
            }
            if(province!=null&&province!=shpdata.province){
                continue;
            }

            if(userauth!=null){
                if(userauth.province!=null&&userauth.province!=shpdata.province){
                    continue;
                }
                if(userauth.area!=null&&userauth.area!=shpdata.area){
                    continue;
                }
                if(userauth.city!=null&&userauth.city!=shpdata.city){
                    continue;
                }
                if(userauth.userId!=null&&userauth.userId!=shpdata.createuser){
                    continue;
                }
            }

            searchshpdatainfos.push(shpdata);
            var filedata=new shpfileinfo(shpdata.province,shpdata.city,shpdata.area,shpdata.filename,shpdata.createtime);
            if(!iscontaindata(filedata)){
                fileshpinfos.push(filedata);
            }
        }
        if(searchshpdatainfos.length==0){
            Util.alert("查询结果为空。");
            return;
        }


        //2，将查到的数据展示到图层上
        for(var i=0;i<searchshpdatainfos.length;i++){
            var sinfo=searchshpdatainfos[i];
            //sinfo.geodatas.show();
            var code = sinfo.province+","+sinfo.city+","+sinfo.area+","+sinfo.type;
            if(allloadmapdatas.indexOf(code)==-1) {
                map.addOverLay(sinfo.geodatas);
                //ActiveFaultDataLayer.push(sinfo.geodatas);
                addDataToMap(sinfo.type, sinfo.geodatas);
                sinfo.geodatas.addEventListener( "click",function(){
                    layerSelectType = type;//选中的图层类型
                    layerSelectUuid = uuid;//选中的图层数据UUID
                    layerSelectBool = true;//是否选中图层数据
                });
                //注册面的悬浮事件
                sinfo.geodatas.addEventListener( "mouseover",function(){
                    layerSelectType = type;//选中的图层类型
                    layerSelectUuid = uuid;//选中的图层数据UUID
                    layerSelectBool = true;//是否选中图层数据
                });
                //注册面的悬浮事件
                sinfo.geodatas.addEventListener( "mouseout",function(){
                    //layerSelectType = null;//选中的图层类型
                    //layerSelectUuid = null;//选中的图层数据UUID
                    layerSelectBool = false;//是否选中图层数据
                });
            }
        }

        for(var i=0;i<searchshpdatainfos.length;i++){
            var sinfo=searchshpdatainfos[i];
            var code = sinfo.province+","+sinfo.city+","+sinfo.area+","+sinfo.type;
            if(allloadmapdatas.indexOf(code)==-1) {
                allloadmapdatas.push(code);
            }
        }

        //1,将所有图层隐藏
        for(var i=0;i<allLayerNameArray.length;i++){
            var id = allLayerNameArray[i][0];//A1_InvestigationRegion
            document.getElementById(id).checked=false;
        }

        for(var i=0;i<=38;i++){
            showHideLayerByTypeBool(i,false);
        }

        //3，图层数据显隐通过省市县加文件名称综合判断，参数为省市县名称加显隐标志

        $("#searchresultDiv").css("z-index", "1100");
        $("#searchresultDiv").show();

        // 初始化表格
        createDataGrid(fileshpinfos);

    };

    var addDataToMap = function(type,geo){
        if(type==1){
            GeologicalSvyPlanningLineDataLayer.push(geo);
        }else if(type==2){
            MainAFSvyRegionDataLayer.push(geo);
        }else if(type==3){
            MaterialPolygonLayerDataLayer.push(geo);
        }else if(type==4){
            TargetRegionDataLayer.push(geo);
        }else if(type==5){
            WorkRegionDataLayer.push(geo);
        }else if(type==6){
            ImageIndexLayerDataLayer.push(geo);
        }else if(type==7){
            RSInterpretationLineDataLayer.push(geo);
        }else if(type==8){
            RSInterpretationPolygonDataLayer.push(geo);
        }else if(type==9){
            AviationMagneticDataLayer.push(geo);
        }else if(type==10){
            CrustIsolineDataLayer.push(geo);
        }else if(type==11){
            GMInterpretationLineDataLayer.push(geo);
        }else if(type==12){
            GravityFieldDataLayer.push(geo);
        }else if(type==13){
            VerticalDeformationDataLayer.push(geo);
        }else if(type==14){
            Rock1LinePreDataLayer.push(geo);
        }else if(type==15){
            Rock1PreDataLayer.push(geo);
        }else if(type==16){
            Rock25LinePreDataLayer.push(geo);
        }else if(type==17){
            Rock25PreDataLayer.push(geo);
        }else if(type==18){
            Rock5LinePreDataLayer.push(geo);
        }else if(type==19){
            Rock5PreDataLayer.push(geo);
        }else if(type==20){
            Stratigraphy1LinePreDataLayer.push(geo);
        }else if(type==21){
            Stratigraphy1PreDataLayer.push(geo);
        }else if(type==22){
            Stratigraphy25LinePreDataLayer.push(geo);
        }else if(type==23){
            Stratigraphy25PreDataLayer.push(geo);
        }else if(type==24){
            Stratigraphy5LinePreDataLayer.push(geo);
        }else if(type==25){
            Stratigraphy5PreDataLayer.push(geo);
        }else if(type==26){
            ActiveFaultDataLayer.push(geo);
        }else if(type==39){
            ActiveFaultpositionerrorDataLayer.push(geo);
        }else if(type==27){
            GeologicalSvyLineDataLayer.push(geo);
        }else if(type==28){
            GeomorphyLineDataLayer.push(geo);
        }else if(type==29){
            GeomorphyPolygonDataLayer.push(geo);
        }else if(type==30){
            GeoProfileLineDataLayer.push(geo);
        }else if(type==31){
            GeomorphySvyLineDataLayer.push(geo);
        }else if(type==32){
            GeomorphySvyRegionDataLayer.push(geo);
        }else if(type==33){
            GeomorphySvyReProfDataLayer.push(geo);
        }else if(type==34){
            DrillProfileDataLayer.push(geo);
        }else if(type==35){
            GeophySvyLineDataLayer.push(geo);
        }else if(type==36){
            GeochemicalAbnSegmentDataLayer.push(geo);
        }else if(type==37){
            GeochemicalSvyLineDataLayer.push(geo);
        }else if(type==38){
            LavaDataLayer.push(geo);
        }
    };

    var downloadFile = function () {
            var type = $("#selectdDtaType1").val();
            console.log(type);
            var rows = $("#dataGrid").datagrid("getSelections");
            if (rows == null || rows.length == 0) {
                Util.alert("请选择一行数据!");
                return;
            }else if(rows.length > 1){
                Util.alert("不能选择多行数据!");
                return;
            }
            else{
                for(var i=0;i<rows.length;i++){
                    rows[i].type = type;
                }
            }
            var paramData = rows.map(function(item){
                return {
                    provinceName:item.province,
                    cityName:item.city,
                    areaName:item.area,
                    type:item.type,
                    savefilename:item.filename,
                }
            })
            var downParams = '';
            paramData.forEach(function (item) {
                downParams= downParams + item.provinceName + ",";
                downParams= downParams + item.cityName + ",";
                downParams= downParams + item.areaName + ",";
                downParams= downParams + item.type + ",";
                downParams= downParams + item.savefilename + ";";
            })
            // console.log(JSON.stringify(paramData));
            // console.log(typeof JSON.stringify(paramData));

            downParams = encodeURIComponent(downParams);
            window.location.href = getServer() + "/hddc/hddcShpDataMapDisplay/download-multipl?downParams=" + downParams;
            // window.location.href = getServer() + "/hddc/hddcShpDataMapDisplay/download-multipl?json=2";

    }

    var createDataGrid= function(data) {
        if(data==undefined)
            return;
        if(data.length>0) {
            for (var i = 0; i < data.length; i++) {
                data[i].pca = data[i].province + data[i].city + data[i].area;
            }
        }
            $("#dataGrid").datagrid({
                fitColumns: true,
                autoRowHeight: true,
                data:data,
                remoteSort:false,
                idField:'pca',
                columns:[[
                    {field:"ck",checkbox:true},
                    {
                        field:'province',sortable:true,
                        title:'省',
                        width:'20%',
                        align:'center',
                    },
                    {
                        field:'city',sortable:true,
                        title:'市',
                        width:'20%',
                        align:'center',
                    },
                    {
                        field:'area',sortable:true,
                        title:'县',
                        width:'18%',
                        align:'center',
                    },
                    {
                        field:'filename',
                        title:'文件名',
                        width:'18%',
                        align:'center',
                    },
                    {
                        field:'createtime',
                        title:'上传日期',
                        sortable:true,
                        width:'22%',
                        align:'center',
                        // formatter:function(value,rowData,rowIndex){
                        //     if (rowData.updateTime == null || rowData.updateTime == '')
                        //         return rowData.createTime;
                        //     else return rowData.updateTime;
                        // }
                    }
                ]],
                toolbar: [{
                    iconCls: 'fa fa-trash-o',
                    text:"删除",
                    handler: function(){
                        deleteData(data);
                    }
                },{
                    iconCls: 'fa fa-download',
                    text:"下载",
                    handler: function(){
                        downloadFile();
                    }
                }],
                pagination: true,
                pageSize: 10,
                loadFilter:pagerFilter,
                onCheck:function (rowIndex,rowData) {
                    displaysearchshpdata(rowData.province,rowData.city,rowData.area,rowData.filename,true);
                },
                onUncheck:function (rowIndex,rowData) {
                    displaysearchshpdata(rowData.province,rowData.city,rowData.area,rowData.filename,false);
                },
                onCheckAll:function (rows) {
                    for(var i=0;i<rows.length;i++){
                        var rowData=rows[i];
                        displaysearchshpdata(rowData.province,rowData.city,rowData.area,rowData.filename,true);
                    }
                    //displayAllsearchshpdata(true);
                },
                onUncheckAll:function (rows) {
                    for(var i=0;i<rows.length;i++){
                        var rowData=rows[i];
                        displaysearchshpdata(rowData.province,rowData.city,rowData.area,rowData.filename,false);
                    }
                    //displayAllsearchshpdata(false);
                }
            });
         $("#dataGrid").datagrid('uncheckAll');
    };

    function pagerFilter(data) {
        if (typeof data.length == 'number' && typeof data.splice == 'function') {   // is array
            data = {
                total: data.length,
                rows: data
            }
        }
        var dg = $(this);
        var opts = dg.datagrid('options');
        var pager = dg.datagrid('getPager');
        pager.pagination({
            onSelectPage: function (pageNum, pageSize) {
                opts.pageNumber = pageNum;
                opts.pageSize = pageSize;
                pager.pagination('refresh', {
                    pageNumber: pageNum,
                    pageSize: pageSize
                });
                dg.datagrid('loadData', data);
            }
        });
        if (!data.originalRows) {
            data.originalRows = (data.rows);
        }
        var start = (opts.pageNumber - 1) * parseInt(opts.pageSize);
        var end = start + parseInt(opts.pageSize);
        data.rows = (data.originalRows.slice(start, end));
        return data;
    }



    var deleteData = function(data) {
        var type = $("#selectdDtaType1").val();
        var rows = $("#dataGrid").datagrid("getSelections");
        if (rows == null || rows.length == 0) {
            Util.alert("请选择一行数据!");
            return;
        }else{
            for(var i=0;i<rows.length;i++){
                rows[i].type = type;
            }
        }
        var paramData = rows.map(function(item){
            return {
                provinceName:item.province,
                cityName:item.city,
                areaName:item.area,
                type:item.type,
                savefilename:item.filename,
            }
        })
        Util.confirm("是否要删除选中的数据?", function() {
            $.ajax({
                url: getServer() + "/hddc/hddcShpDataMapDisplay/deletefile",
                type: "post",
                contentType:"application/json",
                data:JSON.stringify(paramData),
                //     {
                //     paramsVos:paramData
                // },
                success: function (data) {
                    Util.alert(data);
                    createDataGrid();
                }
            });
        }, function() {
            return;
        });
    };

    function displaysearchshpdata(province,city,area,filename,checked) {
        for(var i=0;i<searchshpdatainfos.length;i++){
            var sinfo=searchshpdatainfos[i];
            if(sinfo.province==province&&sinfo.city==city&&sinfo.area==area&&sinfo.filename==filename){
                if(checked){
                    sinfo.geodatas.show();
                }else{
                    sinfo.geodatas.hide();
                }
            }
        }
    }

    var displayAllsearchshpdata = function (checked) {
        for(var i=0;i<searchshpdatainfos.length;i++) {
            var sinfo = searchshpdatainfos[i];
            if (checked) {
                sinfo.geodatas.show();
            } else {
                sinfo.geodatas.hide();
            }
        }
    }

    function iscontaindata(data){
        for(var i=0;i<fileshpinfos.length;i++){
            var filedata=fileshpinfos[i];
            if(filedata.province==data.province&&filedata.city==data.city&&filedata.area==data.area&&filedata.filename==data.filename)
                return true;
        }
        return false;
    }

    ///////////////////////////////////////////////////////////////////////zyt
    //数据图层
    //A1_InvestigationRegion(区域调查)
    var GeologicalSvyPlanningLineDataLayer = [];//1地质调查规划路线-线图层
    var MainAFSvyRegionDataLayer = [];//2主要活动断层制图区-面
    var MaterialPolygonLayerDataLayer = [];//3面状资料图层-面
    var TargetRegionDataLayer = [];//4
    var WorkRegionDataLayer = [];//5工作区-面
    //A3_RemoteSensing（遥感影像）
    var ImageIndexLayerDataLayer = [];//6影像索引表-面
    var RSInterpretationLineDataLayer = [];//7航、卫片解译线-线
    var RSInterpretationPolygonDataLayer = [];//8航、卫片解译面-面
    //A4_GeophysicalField（地球物理学）
    var AviationMagneticDataLayer = [];//9航磁-线
    var CrustIsolineDataLayer = [];//10地壳厚度-线
    var GMInterpretationLineDataLayer = [];//11重磁解译线-线
    var GravityFieldDataLayer = [];//12重力场-线
    var VerticalDeformationDataLayer = [];//13垂直形变-线
    //A5_WorkMapPre（工作地图）
    var Rock1LinePreDataLayer = [];//14-1：1万底图岩体线-线
    var Rock1PreDataLayer = [];//15-1：1万工作底图岩体-面
    var Rock25LinePreDataLayer = [];//16-1：25万底图岩体线-线
    var Rock25PreDataLayer = [];//17-1：25万工作底图岩体-面
    var Rock5LinePreDataLayer = [];//18-1：5万底图岩体线-线
    var Rock5PreDataLayer = [];//19-1：5万工作底图岩体-面
    var Stratigraphy1LinePreDataLayer = [];//20-1：1万底图地层线-线
    var Stratigraphy1PreDataLayer = [];//21-1：1万工作底图地层-面
    var Stratigraphy25LinePreDataLayer = [];//22-1：25万底图地层线-线
    var Stratigraphy25PreDataLayer = [];//23-1：25万工作底图地层-面
    var Stratigraphy5LinePreDataLayer = [];//24-1：5万底图地层线-线
    var Stratigraphy5PreDataLayer = [];//25-1：5万工作底图地层-面
    //B1_GeologicalSurveyMapping（地质调查）
    var ActiveFaultDataLayer = [];//26-活动断层-线
    var ActiveFaultpositionerrorDataLayer = [];//39-活动断层位置误差
    var GeologicalSvyLineDataLayer = [];//27-地质调查路线-线
    var GeomorphyLineDataLayer = [];//28-地貌线-线
    var GeomorphyPolygonDataLayer = [];//29-地貌面-面
    var GeoProfileLineDataLayer = [];//30-地质剖面线-线
    //B2_GeomorphySvy（地貌调查）
    var GeomorphySvyLineDataLayer = [];//31-微地貌测量线-线
    var GeomorphySvyRegionDataLayer = [];//32-微地貌测量面-面
    var GeomorphySvyReProfDataLayer = [];//33-微地貌面测量切线-线
    var DrillProfileDataLayer = [];//34-跨断层钻探剖面-线
    //B5_GeophysicalSurvey（地球物理调查）
    var GeophySvyLineDataLayer = [];//35-地球物理测线-线
    //B6_Geochemical（地球化学调查）
    var GeochemicalAbnSegmentDataLayer = [];//36-地球化学异常区段-线
    var GeochemicalSvyLineDataLayer = [];//37-地球化学探测测线-线
    //B7_Volcano（火山调查）
    var LavaDataLayer = [];//38-熔岩流-面

    var GeologicalSvyPlanningLineDatas = [];//1地质调查规划路线-线图层
    var MainAFSvyRegionDatas = [];//2主要活动断层制图区-面
    var MaterialPolygonsDatas = [];//3面状资料图层-面
    var TargetRegionDatas = [];//4
    var WorkRegionDatas = [];//5工作区-面
    //A3_RemoteSensing（遥感影像）
    var ImageIndexsDatas = [];//6影像索引表-面
    var RSInterpretationLineDatas = [];//7航、卫片解译线-线
    var RSInterpretationPolygonDatas = [];//8航、卫片解译面-面
    //A4_GeophysicalField（地球物理学）
    var AviationMagneticDatas = [];//9航磁-线
    var CrustIsolineDatas = [];//10地壳厚度-线
    var GMInterpretationLineDatas = [];//11重磁解译线-线
    var GravityFieldDatas = [];//12重力场-线
    var VerticalDeformationDatas = [];//13垂直形变-线
    //A5_WorkMapPre（工作地图）
    var Rock1LinePreDatas = [];//14-1：1万底图岩体线-线
    var Rock1PreDatas = [];//15-1：1万工作底图岩体-面
    var Rock25LinePreDatas = [];//16-1：25万底图岩体线-线
    var Rock25PreDatas = [];//17-1：25万工作底图岩体-面
    var Rock5LinePreDatas = [];//18-1：5万底图岩体线-线
    var Rock5PreDatas = [];//19-1：5万工作底图岩体-面
    var Stratigraphy1LinePreDatas = [];//20-1：1万底图地层线-线
    var Stratigraphy1PreDatas = [];//21-1：1万工作底图地层-面
    var Stratigraphy25LinePreDatas = [];//22-1：25万底图地层线-线
    var Stratigraphy25PreDatas = [];//23-1：25万工作底图地层-面
    var Stratigraphy5LinePreDatas = [];//24-1：5万底图地层线-线
    var Stratigraphy5PreDatas = [];//25-1：5万工作底图地层-面
    //B1_GeologicalSurveyMapping（地质调查）
    var ActiveFaultDatas = [];//26-活动断层-线
    var ActiveFaultpositionerrorDatas = [];//39-活动断层位置误差
    var GeologicalSvyLineDatas = [];//27-地质调查路线-线
    var GeomorphyLineDatas = [];//28-地貌线-线
    var GeomorphyPolygonDatas = [];//29-地貌面-面
    var GeoProfileLineDatas = [];//30-地质剖面线-线
    //B2_GeomorphySvy（地貌调查）
    var GeomorphySvyLineDatas = [];//31-微地貌测量线-线
    var GeomorphySvyRegionDatas = [];//32-微地貌测量面-面
    var GeomorphySvyReProfDatas = [];//33-微地貌面测量切线-线
    var DrillProfileDatas = [];//34-跨断层钻探剖面-线
    //B5_GeophysicalSurvey（地球物理调查）
    var GeophySvyLineDatas = [];//35-地球物理测线-线
    //B6_Geochemical（地球化学调查）
    var GeochemicalAbnSegmentDatas = [];//36-地球化学异常区段-线
    var GeochemicalSvyLineDatas = [];//37-地球化学探测测线-线
    //B7_Volcano（火山调查）
    var LavaDatas = [];//38-熔岩流-面

    //图层显示|隐藏数组
    var layerShowHideBoolArray = ["图层显示|隐藏数组"];
    //设置全部显示
    for(var i=1;i<=39;i++){
        //layerShowHideBoolArray.push(true);
        layerShowHideBoolArray.push(false);
    }

    //全部图层名称数组
    var allLayerNameArray = [];
    //添加全部图层名称数组
    var addAllLayerNameArray = function(){
        var array = [];
        array.push("区域调查");
        array.push("遥感影像");
        array.push("地球物理学");
        array.push("工作地图");
        array.push("地质调查");
        array.push("地貌调查");
        array.push("地球物理调查");
        array.push("地球化学调查");
        array.push("火山调查");
        for(var i=0;i<array.length;i++){
            var name = array[i];
            if(i==0){//A1_InvestigationRegion(区域调查)
                var id = "A1_InvestigationRegion";
                //图层名称数组
                var layerNameArray = [];
                //A1_InvestigationRegion(区域调查)
                layerNameArray.push([1,"地质调查规划路线-线图层","GeologicalSvyPlanningLine"]);
                layerNameArray.push([2,"主要活动断层制图区-面","MainAFSvyRegion"]);
                layerNameArray.push([3,"面状资料图层-面","MaterialPolygonLayer"]);
                layerNameArray.push([4,"目标区-面","TargetRegion"]);
                layerNameArray.push([5,"工作区-面","WorkRegion"]);
                //添加图层名称数组
                allLayerNameArray.push([id,name,layerNameArray]);
            }else if(i==1){//A3_RemoteSensing（遥感影像）
                var id = "A3_RemoteSensing";
                //图层名称数组
                var layerNameArray = [];
                layerNameArray.push([6,"影像索引表-面","ImageIndexLayer"]);
                layerNameArray.push([7,"航、卫片解译线-线","RSInterpretationLine"]);
                layerNameArray.push([8,"航、卫片解译面-面","RSInterpretationPolygon"]);
                //添加图层名称数组
                allLayerNameArray.push([id,name,layerNameArray]);
            }else if(i==2){//A4_GeophysicalField（地球物理学）
                var id = "A4_GeophysicalField";
                //图层名称数组
                var layerNameArray = [];
                layerNameArray.push([9,"航磁-线","AviationMagnetic"]);
                layerNameArray.push([10,"地壳厚度-线","CrustIsoline"]);
                layerNameArray.push([11,"重磁解译线-线","GMInterpretationLine"]);
                layerNameArray.push([12,"重力场-线","GravityField"]);
                layerNameArray.push([13,"垂直形变-线","VerticalDeformation"]);
                //添加图层名称数组
                allLayerNameArray.push([id,name,layerNameArray]);
            }else if(i==3){//A5_WorkMapPre（工作地图）
                var id = "A5_WorkMapPre";
                //图层名称数组
                var layerNameArray = [];
                layerNameArray.push([14,"1：1万底图岩体线-线","Rock1LinePre"]);
                layerNameArray.push([15,"1：1万工作底图岩体-面","Rock1Pre"]);
                layerNameArray.push([16,"1：25万底图岩体线-线","Rock25LinePre"]);
                layerNameArray.push([17,"1：25万工作底图岩体-面","Rock25Pre"]);
                layerNameArray.push([18,"1：5万底图岩体线-线","Rock5LinePre"]);
                layerNameArray.push([19,"1：5万工作底图岩体-面","Rock5Pre"]);
                layerNameArray.push([20,"1：1万底图地层线-线","Stratigraphy1LinePre"]);
                layerNameArray.push([21,"1：1万工作底图地层-面","Stratigraphy1Pre"]);
                layerNameArray.push([22,"1：25万底图地层线-线","Stratigraphy25LinePre"]);
                layerNameArray.push([23,"1：25万工作底图地层-面","Stratigraphy25Pre"]);
                layerNameArray.push([24,"1：5万底图地层线-线","Stratigraphy5LinePre"]);
                layerNameArray.push([25,"1：5万工作底图地层-面","Stratigraphy5Pre"]);
                //添加图层名称数组
                allLayerNameArray.push([id,name,layerNameArray]);
            }else if(i==4){//B1_GeologicalSurveyMapping（地质调查）
                var id = "B1_GeologicalSurveyMapping";
                //图层名称数组
                var layerNameArray = [];
                layerNameArray.push([26,"活动断层-线","ActiveFault"]);
                layerNameArray.push([39,"活动断层位置误差","ActiveFaultpositionerror"]);
                layerNameArray.push([27,"地质调查路线-线","GeologicalSvyLine"]);
                layerNameArray.push([28,"地貌线-线","GeomorphyLine"]);
                layerNameArray.push([29,"地貌面-面","GeomorphyPolygon"]);
                layerNameArray.push([30,"地质剖面线-线","GeoProfileLine"]);

                //添加图层名称数组
                allLayerNameArray.push([id,name,layerNameArray]);
            }else if(i==5){//B2_GeomorphySvy（地貌调查）
                var id = "B2_GeomorphySvy";
                //图层名称数组
                var layerNameArray = [];
                layerNameArray.push([31,"微地貌测量线-线","GeomorphySvyLine"]);
                layerNameArray.push([32,"微地貌测量面-面","GeomorphySvyRegion"]);
                layerNameArray.push([33,"微地貌面测量切线-线","GeomorphySvyReProf"]);
                layerNameArray.push([34,"跨断层钻探剖面-线","DrillProfile"]);
                //添加图层名称数组
                allLayerNameArray.push([id,name,layerNameArray]);
            }else if(i==6){//B5_GeophysicalSurvey（地球物理调查）
                var id = "B5_GeophysicalSurvey";
                //图层名称数组
                var layerNameArray = [];
                layerNameArray.push([35,"地球物理测线-线","GeophySvyLine"]);
                //添加图层名称数组
                allLayerNameArray.push([id,name,layerNameArray]);
            }else if(i==7){//B6_Geochemical（地球化学调查）
                var id = "B6_Geochemical";
                //图层名称数组
                var layerNameArray = [];
                layerNameArray.push([36,"地球化学异常区段-线","GeochemicalAbnSegment"]);
                layerNameArray.push([37,"地球化学探测测线-线","GeochemicalSvyLine"]);
                //添加图层名称数组
                allLayerNameArray.push([id,name,layerNameArray]);
            }else if(i==8){//B7_Volcano（火山调查）
                var id = "B7_Volcano";
                //图层名称数组
                var layerNameArray = [];
                layerNameArray.push([38,"熔岩流-面","Lava"]);
                //添加图层名称数组
                allLayerNameArray.push([id,name,layerNameArray]);
            }
        }
    };

    var displaylayer1=false;
    var displaylayer2=false;
    var displaylayer3=false;
    var displaylayer4=false;
    var displaylayer5=false;
    var displaylayer6=false;
    var displaylayer7=false;
    var displaylayer8=false;
    var displaylayer9=false;
    var displaylayer10=false;
    var displaylayer11=false;
    var displaylayer12=false;
    var displaylayer13=false;
    var displaylayer14=false;
    var displaylayer15=false;
    var displaylayer16=false;
    var displaylayer17=false;
    var displaylayer18=false;
    var displaylayer19=false;
    var displaylayer20=false;
    var displaylayer21=false;
    var displaylayer22=false;
    var displaylayer23=false;
    var displaylayer24=false;
    var displaylayer25=false;
    var displaylayer26=false;
    var displaylayer27=false;
    var displaylayer28=false;
    var displaylayer29=false;
    var displaylayer30=false;
    var displaylayer31=false;
    var displaylayer32=false;
    var displaylayer33=false;
    var displaylayer34=false;
    var displaylayer35=false;
    var displaylayer36=false;
    var displaylayer37=false;
    var displaylayer38=false;
    var displaylayer39=false;
    //var loading;
    var testJudge;

    //查询并添加全部数据到地图上
    var initQueryAddAllData = function(){
        /*setTimeout(function(){
            //查询并添加全部数据到地图上
            initQueryAddAllData();
            setTimeout(function(){
                //查询并添加全部数据到地图上
                initQueryAddAllData();
            },1000);
        },1000);*/
        //添加全部图层名称数组
        addAllLayerNameArray();
        //添加第一级图层选择控件
        addFirstLayerCheckBoxControl();
        //添加地图图层的右键菜单
        addMapMenuToLayer();
        //A1_InvestigationRegion(区域调查)

        /*loading = Loading({
            text : "正在加载数据，请稍后。"
        });
        loading.show();*/
        /*//1地质调查规划路线-线
        addGeologicalSvyPlanningLineData();
        //2主要活动断层制图区-面
        addMainAFSvyRegionData();
        //3面状资料图层-面
        addMaterialPolygonLayerData();
        //4目标区-面
        addTargetRegionData();
        //5工作区-面
        addWorkRegionData();
        //6影像索引表-面
        addImageIndexLayerData();
        //7航、卫片解译线-线
        addRSInterpretationLineData();
        //8航、卫片解译面-面
        addRSInterpretationPolygonData();
        //9航磁-线
        addAviationMagneticData();
        //10地壳厚度-线
        addCrustIsolineData();
        //11重磁解译线-线
        addGMInterpretationLineData();
        //12重力场-线
        addGravityFieldData();
        //13垂直形变-线
        addVerticalDeformationData();
        //14-1：1万底图岩体线-线
        addRock1LinePreData();
        //15-1：1万工作底图岩体-面
        addRock1PreData();
        //16-1：25万底图岩体线-线
        addRock25LinePreData();
        //17-1：25万工作底图岩体-面
        addRock25PreData();
        //18-1：5万底图岩体线-线
        addRock5LinePreData();
        //19-1：5万工作底图岩体-面
        addRock5PreData();
        //20-1：1万底图地层线-线
        addStratigraphy1LinePreData();
        //21-1：1万工作底图地层-面
        addStratigraphy1PreData();
        //22-1：25万底图地层线-线
        addStratigraphy25LinePreData();
        //23-1：25万工作底图地层-面
        addStratigraphy25PreData();
        //24-1：5万底图地层线-线
        addStratigraphy5LinePreData();
        //25-1：5万工作底图地层-面
        addStratigraphy5PreData();
        //26-活动断层-线
        addActiveFaultData();
        //39-活动断层位置误差
        addActiveFaultpositionerrorData();
        //27-地质调查路线-线
        addGeologicalSvyLineData();
        //28-地貌线-线
        addGeomorphyLineData();
        //29-地貌面-面
        addGeomorphyPolygonData();
        //30-地质剖面线-线
        addGeoProfileLineData();
        //31-微地貌测量线-线
        addGeomorphySvyLineData();
        //32-微地貌测量面-面
        addGeomorphySvyRegionData();
        //33-微地貌面测量切线-线
        addGeomorphySvyReProfData();
        //34-跨断层钻探剖面-线
        addDrillProfileData();
        //35-地球物理测线-线
        addGeophySvyLineData();
        //36-地球化学异常区段-线
        addGeochemicalAbnSegmentData();
        //37-地球化学探测测线-线
        addGeochemicalSvyLineData();
        //38-熔岩流-面
        addLavaData();*/

        //testJudge();
        /*testJudge = setInterval(function(){
            judgeDataSucceed();
        },1000);*/
    };



    function judgeDataSucceed() {
        if (displaylayer1 && displaylayer2 && displaylayer3 && displaylayer4 && displaylayer5 && displaylayer6 &&
            displaylayer7 && displaylayer8 && displaylayer9 && displaylayer10 && displaylayer11 && displaylayer12 &&
            displaylayer13 && displaylayer14 && displaylayer15 && displaylayer16 && displaylayer17 && displaylayer18 &&
            displaylayer19 && displaylayer20 && displaylayer21 && displaylayer22 && displaylayer23 && displaylayer24 &&
            displaylayer25 && displaylayer26 && displaylayer27 && displaylayer28 && displaylayer29 && displaylayer30 &&
            displaylayer31 && displaylayer32 && displaylayer33 && displaylayer34 && displaylayer35 && displaylayer36 &&
            displaylayer37 && displaylayer38 && displaylayer39) {
            //loading.close();
            clearInterval(testJudge);
        }
    }

    //获取线路|面经纬度数组
    var getLonLatArray = function(LonLatString){
        var LonLatArray = [];//经纬度数组
        var strArray = LonLatString.split(";");
        if(strArray!=null && strArray.length>0){
            for(var i=0;i<strArray.length;i++){
                var str = strArray[i];
                var lonlatStrArray = str.split(",");
                if(lonlatStrArray!=null && lonlatStrArray.length==2){
                    var lonStr = lonlatStrArray[0];
                    var latStr = lonlatStrArray[1];
                    if(lonStr!="" && latStr!=""){
                        var lon = parseFloat(lonStr);
                        var lat = parseFloat(latStr);
                        if(lon>0 && lon<180 && lat>0 && lat<90){
                            //经纬度
                            var lonlat = [lon,lat];
                            //添加经纬度
                            LonLatArray.push(lonlat);
                        }
                    }
                }
            }
        }
        return LonLatArray;
    };

    var getHddcGeologicalsvyplanninglineController = function(){
        return getServer() + "/hddc/hddcGeologicalsvyplanninglines";
    };
    //1-地质调查规划路线-线
    var addGeologicalSvyPlanningLineData = function(){
        console.log("1查询地质调查规划路线-线");
        $.ajax({
            url: getHddcGeologicalsvyplanninglineController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GeologicalSvyPlanningLineDatas=data;
                displaylayer1=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GeologicalSvyPlanningLineDataLayer = addLineToMap(LonLatArray, GeologicalSvyPlanningLineDataLayer, 1, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer1=true;
                console.log("1-地质调查规划路线-线");
            }
        });
    };
    var getHddcMainafsvyregionController = function(){
        return getServer() + "/hddc/hddcMainafsvyregions";
    };
    //2-主要活动断层制图区-面
    var addMainAFSvyRegionData = function(){
        console.log("2查询主要活动断层制图区-面");
        $.ajax({
            url: getHddcMainafsvyregionController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                MainAFSvyRegionDatas=data;
                displaylayer2=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加面
                            MainAFSvyRegionDataLayer = addPolygonToMap(LonLatArray, MainAFSvyRegionDataLayer, 2, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer2=true;
                console.log("2-主要活动断层制图区-面");
            }
        });
    };
    var getHddcMaterialpolygonlayerController = function(){
        return getServer() + "/hddc/hddcMaterialpolygonlayers";
    };
    //3-面状资料图层-面
    var addMaterialPolygonLayerData = function(){
        console.log("3-面状资料图层-面");
        $.ajax({
            url: getHddcMaterialpolygonlayerController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                MaterialPolygonsDatas=data;

                displaylayer3=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            MaterialPolygonLayerDataLayer = addPolygonToMap(LonLatArray, MaterialPolygonLayerDataLayer, 3, uuid, data[i].province, data[i].city, data[i].area, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer3=true;
                console.log("3-面状资料图层-面");
            }
        });
    };
    var getHddcTargetregionController = function(){
        return getServer() + "/hddc/hddcTargetregions";
    };
    //4-目标区-面
    var addTargetRegionData = function(){
        console.log("4-目标区-面");
        $.ajax({
            url: getHddcTargetregionController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                TargetRegionDatas=data;
                displaylayer4=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            TargetRegionDataLayer = addPolygonToMap(LonLatArray, TargetRegionDataLayer, 4, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer4=true;
                console.log("4-目标区-面");
            }
        });
    };
    var getHddcWorkregionController = function(){
        return getServer() + "/hddc/hddcWorkregions";
    };
    //5-工作区-面
    var addWorkRegionData = function(){
        console.log("5-工作区-面");
        $.ajax({
            url: getHddcWorkregionController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                WorkRegionDatas=data;
                displaylayer5=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            WorkRegionDataLayer = addPolygonToMap(LonLatArray, WorkRegionDataLayer, 5, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer5=true;
                console.log("5-工作区-面");
            }
        });
    };
    var getHddcImageindexlayerController = function(){
        return getServer() + "/hddc/hddcImageindexlayers";
    };
    //6-影像索引表-面
    var addImageIndexLayerData = function(){
        console.log("6-影像索引表-面");
        $.ajax({
            url: getHddcImageindexlayerController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                ImageIndexsDatas=data;

                displaylayer6=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            ImageIndexLayerDataLayer = addPolygonToMap(LonLatArray, ImageIndexLayerDataLayer, 6, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer6=true;
                console.log("6-影像索引表-面");
            }
        });
    };
    var getHddcRsinterpretationlineController = function(){
        return getServer() + "/hddc/hddcRsinterpretationlines";
    };
    //7-航、卫片解译线-线
    var addRSInterpretationLineData = function(){
        console.log("7-航、卫片解译线-线");
        $.ajax({
            url: getHddcRsinterpretationlineController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                RSInterpretationLineDatas=data;
                displaylayer7=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            RSInterpretationLineDataLayer = addLineToMap(LonLatArray, RSInterpretationLineDataLayer, 7, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer7=true;
                console.log("7-航、卫片解译线-线");
            }
        });
    };
    var getHddcRsinterpretationpolygonController = function(){
        return getServer() + "/hddc/hddcRsinterpretationpolygons";
    };
    //8-航、卫片解译面-面
    var addRSInterpretationPolygonData = function(){
        console.log("8-航、卫片解译面-面");
        $.ajax({
            url: getHddcRsinterpretationpolygonController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                RSInterpretationPolygonDatas=data;
                displaylayer8=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            RSInterpretationPolygonDataLayer = addPolygonToMap(LonLatArray, RSInterpretationPolygonDataLayer, 8, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer8=true;
                console.log("8-航、卫片解译面-面");
            }
        });
    };
    var getHddcAviationmagneticController = function(){
        return getServer() + "/hddc/hddcAviationmagnetics";
    };
    //9-航磁-线
    var addAviationMagneticData = function(){
        console.log("9-航磁-线");
        $.ajax({
            url: getHddcAviationmagneticController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                AviationMagneticDatas=data;
                displaylayer9=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            AviationMagneticDataLayer = addLineToMap(LonLatArray, AviationMagneticDataLayer, 9, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer9=true;
                console.log("9-航磁-线");
            }
        });
    };
    var getHddcCrustisolineController = function(){
        return getServer() + "/hddc/hddcCrustisolines";
    };
    //10-地壳厚度-线
    var addCrustIsolineData = function(){
        console.log("10-地壳厚度-线");
        $.ajax({
            url: getHddcCrustisolineController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                CrustIsolineDatas=data;
                displaylayer10=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            CrustIsolineDataLayer = addLineToMap(LonLatArray, CrustIsolineDataLayer, 10, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer10=true;
                console.log("10-地壳厚度-线");
            }
        });
    };
    var getHddcGminterpretationlineController = function(){
        return getServer() + "/hddc/hddcGminterpretationlines";
    };
    //11-重磁解译线-线
    var addGMInterpretationLineData = function(){
        console.log("11-重磁解译线-线");
        $.ajax({
            url: getHddcGminterpretationlineController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GMInterpretationLineDatas=data;
                displaylayer11=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GMInterpretationLineDataLayer = addLineToMap(LonLatArray, GMInterpretationLineDataLayer, 11, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer11=true;
                console.log("11-重磁解译线-线");
            }
        });
    };
    var getHddcGravityfieldController = function(){
        return getServer() + "/hddc/hddcGravityfields";
    };
    //12-重力场-线
    var addGravityFieldData = function(){
        console.log("12-重力场-线");
        $.ajax({
            url: getHddcGravityfieldController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GravityFieldDatas=data;
                displaylayer12=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GravityFieldDataLayer = addLineToMap(LonLatArray, GravityFieldDataLayer, 12, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer12=true;
                console.log("12-重力场-线");
            }
        });
    };
    var getHddcVerticaldeformationController = function(){
        return getServer() + "/hddc/hddcVerticaldeformations";
    };
    //13-垂直形变-线
    var addVerticalDeformationData = function(){
        console.log("13-垂直形变-线");
        $.ajax({
            url: getHddcVerticaldeformationController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                VerticalDeformationDatas=data;
                displaylayer13=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            VerticalDeformationDataLayer = addLineToMap(LonLatArray, VerticalDeformationDataLayer, 13, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer13=true;
                console.log("13-垂直形变-线");
            }
        });
    };
    var getHddcRock1linepreController = function(){
        return getServer() + "/hddc/hddcRock1linepres";
    };
    //14-1：1万底图岩体线-线
    var addRock1LinePreData = function(){
        console.log("14-1：1万底图岩体线-线");
        $.ajax({
            url: getHddcRock1linepreController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                Rock1LinePreDatas=data;
                displaylayer14=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            Rock1LinePreDataLayer = addLineToMap(LonLatArray, Rock1LinePreDataLayer, 14, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer14=true;
                console.log("14-1：1万底图岩体线-线");
            }
        });
    };
    var getHddcRock1preController = function(){
        return getServer() + "/hddc/hddcRock1pres";
    };
    //15-1：1万工作底图岩体-面
    var addRock1PreData = function(){
        console.log("15-1：1万工作底图岩体-面");
        $.ajax({
            url: getHddcRock1preController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                Rock1PreDatas=data;
                displaylayer15=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            Rock1PreDataLayer = addPolygonToMap(LonLatArray, Rock1PreDataLayer, 15, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer15=true;
                console.log("15-1：1万工作底图岩体-面");
            }
        });
    };
    var getHddcRock25linepreController = function(){
        return getServer() + "/hddc/hddcRock25linepres";
    };
    //16-1：25万底图岩体线-线
    var addRock25LinePreData = function(){
        console.log("16-1：25万底图岩体线-线");
        $.ajax({
            url: getHddcRock25linepreController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                Rock25LinePreDatas=data;
                displaylayer16=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            Rock25LinePreDataLayer = addLineToMap(LonLatArray, Rock25LinePreDataLayer, 16, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer16=true;
                console.log("16-1：25万底图岩体线-线");
            }
        });
    };
    var getHddcRock25preController = function(){
        return getServer() + "/hddc/hddcRock25pres";
    };
    //17-1：25万工作底图岩体-面
    var addRock25PreData = function(){
        console.log("17-1：25万工作底图岩体-面");
        $.ajax({
            url: getHddcRock25preController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                Rock25PreDatas=data;
                displaylayer17=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            Rock25PreDataLayer = addPolygonToMap(LonLatArray, Rock25PreDataLayer, 17, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer17=true;
                console.log("17-1：25万工作底图岩体-面");
            }
        });
    };
    var getHddcRock5linepreController = function(){
        return getServer() + "/hddc/hddcRock5linepres";
    };
    //18-1：5万底图岩体线-线
    var addRock5LinePreData = function(){
        console.log("18-1：5万底图岩体线-线");
        $.ajax({
            url: getHddcRock5linepreController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                Rock5LinePreDatas=data;
                displaylayer18=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            Rock5LinePreDataLayer = addLineToMap(LonLatArray, Rock5LinePreDataLayer, 18, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer18=true;
                console.log("18-1：5万底图岩体线-线");
            }
        });
    };
    var getHddcRock5preController = function(){
        return getServer() + "/hddc/hddcRock5pres";
    };
    //19-1：5万工作底图岩体-面
    var addRock5PreData = function(){
        console.log("19-1：5万工作底图岩体-面");
        $.ajax({
            url: getHddcRock5preController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                Rock5PreDatas=data;
                displaylayer19=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            Rock5PreDataLayer = addPolygonToMap(LonLatArray, Rock5PreDataLayer, 19, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer19=true;
                console.log("19-1：5万工作底图岩体-面");
            }
        });
    };
    var getHddcStratigraphy1linepreController = function(){
        return getServer() + "/hddc/hddcStratigraphy1linepres";
    };
    //20-1：1万底图地层线-线
    var addStratigraphy1LinePreData = function(){
        console.log("20-1：1万底图地层线-线");
        $.ajax({
            url: getHddcStratigraphy1linepreController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                Stratigraphy1LinePreDatas=data;
                displaylayer20=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            Stratigraphy1LinePreDataLayer = addLineToMap(LonLatArray, Stratigraphy1LinePreDataLayer, 20, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer20=true;
                console.log("20-1：1万底图地层线-线");
            }
        });
    };
    var getHddcStratigraphy1preController = function(){
        return getServer() + "/hddc/hddcStratigraphy1pres";
    };
    //21-1：1万工作底图地层-面
    var addStratigraphy1PreData = function(){
        console.log("21-1：1万工作底图地层-面");
        $.ajax({
            url: getHddcStratigraphy1preController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                Stratigraphy1PreDatas=data;
                displaylayer21=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            Stratigraphy1PreDataLayer = addPolygonToMap(LonLatArray, Stratigraphy1PreDataLayer, 21, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer21=true;
                console.log("21-1：1万工作底图地层-面");
            }
        });
    };
    var getHddcStratigraphy25linepreController = function(){
        return getServer() + "/hddc/hddcStratigraphy25linepres";
    };
    //22-1：25万底图地层线-线
    var addStratigraphy25LinePreData = function(){
        console.log("22-1：25万底图地层线-线");
        $.ajax({
            url: getHddcStratigraphy25linepreController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                Stratigraphy25LinePreDatas=data;
                displaylayer22=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            Stratigraphy25LinePreDataLayer = addLineToMap(LonLatArray, Stratigraphy25LinePreDataLayer, 22, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer22=true;
                console.log("22-1：25万底图地层线-线");
            }
        });
    };
    var getHddcStratigraphy25preController = function(){
        return getServer() + "/hddc/hddcStratigraphy25pres";
    };
    //23-1：25万工作底图地层-面
    var addStratigraphy25PreData = function(){
        console.log("23-1：25万工作底图地层-面");
        $.ajax({
            url: getHddcStratigraphy25preController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                Stratigraphy25PreDatas=data;
                displaylayer23=false;
                for(var i=0;i<data.length;i++){
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString=datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            Stratigraphy25PreDataLayer = addPolygonToMap(LonLatArray, Stratigraphy25PreDataLayer, 23, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer23=true;
                console.log("23-1：25万工作底图地层-面");
            }
        });
    };
    var getHddcStratigraphy5linepreController = function(){
        return getServer() + "/hddc/hddcStratigraphy5linepres";
    };
    //24-1：5万底图地层线-线
    var addStratigraphy5LinePreData = function(){
        console.log("24-1：5万底图地层线-线");
        $.ajax({
            url: getHddcStratigraphy5linepreController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                Stratigraphy5LinePreDatas=data;
                displaylayer24=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            Stratigraphy5LinePreDataLayer = addLineToMap(LonLatArray, Stratigraphy5LinePreDataLayer, 24, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer24=true;
                console.log("24-1：5万底图地层线-线");
            }
        });
    };
    var getHddcStratigraphy5preController = function(){
        return getServer() + "/hddc/hddcStratigraphy5pres";
    };
    //25-1：5万工作底图地层-面
    var addStratigraphy5PreData = function(){
        console.log("25-1：5万工作底图地层-面");
        $.ajax({
            url: getHddcStratigraphy5preController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                Stratigraphy5PreDatas=data;
                displaylayer25=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            Stratigraphy5PreDataLayer = addPolygonToMap(LonLatArray, Stratigraphy5PreDataLayer, 25, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer25=true;
                console.log("25-1：5万工作底图地层-面");
            }
        });
    };
    var getHddcActivefaultController = function(){
        return getServer() + "/hddc/hddcActivefaults";
    };
    //26-活动断层-线
    var addActiveFaultData = function(){
        console.log("26-活动断层-线");
        $.ajax({
            url: getHddcActivefaultController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                ActiveFaultDatas=data;
                displaylayer26=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            ActiveFaultDataLayer = addLineToMap(LonLatArray, ActiveFaultDataLayer, 26, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer26=true;
                console.log("26-活动断层-线");
            }
        });
    };

    var getHddcActivefaultpositionerrorController = function(){
        return getServer() + "/hddc/hddcActivefaultspositionerror";
    };
    //39-活动断层位置误差
    var addActiveFaultpositionerrorData = function(){
        console.log("39-活动断层位置误差");
        $.ajax({
            url: getHddcActivefaultpositionerrorController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                ActiveFaultpositionerrorDatas=data;
                displaylayer39=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            //ActiveFaultpositionerrorDataLayer = addLineToMap(LonLatArray, ActiveFaultpositionerrorDataLayer, 26, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                            ActiveFaultpositionerrorDataLayer = addPolygonToMap(LonLatArray, ActiveFaultpositionerrorDataLayer, 39, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer39=true;
                console.log("39-活动断层位置误差");
            }
        });
    };
    var getHddcGeologicalsvylineController = function(){
        return getServer() + "/hddc/hddcGeologicalsvylines";
    };
    //27-地质调查路线-线
    var addGeologicalSvyLineData = function(){
        console.log("27-地质调查路线-线");
        $.ajax({
            url: getHddcGeologicalsvylineController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GeologicalSvyLineDatas=data;
                displaylayer27=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GeologicalSvyLineDataLayer = addLineToMap(LonLatArray, GeologicalSvyLineDataLayer, 27, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer27=true;
                console.log("27-地质调查路线-线");
            }
        });
    };
    var getHddcGeomorphylineController = function(){
        return getServer() + "/hddc/hddcGeomorphylines";
    };
    //28-地貌线-线
    var addGeomorphyLineData = function(){
        console.log("28-地貌线-线");
        $.ajax({
            url: getHddcGeomorphylineController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GeomorphyLineDatas=data;
                displaylayer28=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GeomorphyLineDataLayer = addLineToMap(LonLatArray, GeomorphyLineDataLayer, 28, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer28=true;
                console.log("28-地貌线-线");
            }
        });
    };
    var getHddcGeomorphypolygonController = function(){
        return getServer() + "/hddc/hddcGeomorphypolygons";
    };
    //29-地貌面-面
    var addGeomorphyPolygonData = function(){
        console.log("29-地貌面-面");
        $.ajax({
            url: getHddcGeomorphypolygonController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GeomorphyPolygonDatas=data;
                displaylayer29=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GeomorphyPolygonDataLayer = addPolygonToMap(LonLatArray, GeomorphyPolygonDataLayer, 29, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer29=true;
                console.log("29-地貌面-面");
            }
        });
    };
    var getHddcGeoprofilelineController = function(){
        return getServer() + "/hddc/hddcGeoprofilelines";
    };
    //30-地质剖面线-线
    var addGeoProfileLineData = function(){
        console.log("30-地质剖面线-线");
        $.ajax({
            url: getHddcGeoprofilelineController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GeoProfileLineDatas=data;
                displaylayer30=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GeoProfileLineDataLayer = addLineToMap(LonLatArray, GeoProfileLineDataLayer, 30, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer30=true;
                console.log("30-地质剖面线-线");
            }
        });
    };
    var getHddcGeomorphysvylineController = function(){
        return getServer() + "/hddc/hddcGeomorphysvylines";
    };
    //31-微地貌测量线-线
    var addGeomorphySvyLineData = function(){
        console.log("31-微地貌测量线-线");
        $.ajax({
            url: getHddcGeomorphysvylineController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GeomorphySvyLineDatas=data;
                displaylayer31=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GeomorphySvyLineDataLayer = addLineToMap(LonLatArray, GeomorphySvyLineDataLayer, 31, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer31=true;
                console.log("31-微地貌测量线-线");
            }
        });
    };
    var getHddcGeomorphysvyregionController = function(){
        return getServer() + "/hddc/hddcGeomorphysvyregions";
    };
    //32-微地貌测量面-面
    var addGeomorphySvyRegionData = function(){
        console.log("32-微地貌测量面-面");
        $.ajax({
            url: getHddcGeomorphysvyregionController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GeomorphySvyRegionDatas=data;
                displaylayer32=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GeomorphySvyRegionDataLayer = addPolygonToMap(LonLatArray, GeomorphySvyRegionDataLayer, 32, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer32=true;
                console.log("32-微地貌测量面-面");
            }
        });
    };
    var getHddcGeomorphysvyreprofController = function(){
        return getServer() + "/hddc/hddcGeomorphysvyreprofs";
    };
    //33-微地貌面测量切线-线
    var addGeomorphySvyReProfData = function(){
        console.log("33-微地貌面测量切线-线");
        $.ajax({
            url: getHddcGeomorphysvyreprofController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GeomorphySvyReProfDatas=data;
                displaylayer33=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GeomorphySvyReProfDataLayer = addLineToMap(LonLatArray, GeomorphySvyReProfDataLayer, 33, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer33=true;
                console.log("33-微地貌面测量切线-线");
            }
        });
    };
    var getHddcDrillprofileController = function(){
        return getServer() + "/hddc/hddcDrillprofiles";
    };
    //34-跨断层钻探剖面-线
    var addDrillProfileData = function(){
        console.log("34-跨断层钻探剖面-线");
        $.ajax({
            url: getHddcDrillprofileController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                DrillProfileDatas=data;
                displaylayer34=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            DrillProfileDataLayer = addLineToMap(LonLatArray, DrillProfileDataLayer, 34, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer34=true;
                console.log("34-跨断层钻探剖面-线");
            }
        });
    };
    var getHddcGeophysvylineController = function(){
        return getServer() + "/hddc/hddcGeophysvylines";
    };
    //35-地球物理测线-线
    var addGeophySvyLineData = function(){
        console.log("35-地球物理测线-线");
        $.ajax({
            url: getHddcGeophysvylineController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GeophySvyLineDatas=data;
                displaylayer35=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GeophySvyLineDataLayer = addLineToMap(LonLatArray, GeophySvyLineDataLayer, 35, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer35=true;
                console.log("35-地球物理测线-线");
            }
        });
    };
    var getHddcGeochemicalabnsegmentController = function () {
        return getServer() + "/hddc/hddcGeochemicalabnsegments";
    };
    //36-地球化学异常区段-线
    var addGeochemicalAbnSegmentData = function(){
        console.log("36-地球化学异常区段-线");
        $.ajax({
            url: getHddcGeochemicalabnsegmentController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GeochemicalAbnSegmentDatas=data;
                displaylayer36=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GeochemicalAbnSegmentDataLayer = addLineToMap(LonLatArray, GeochemicalAbnSegmentDataLayer, 36, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer36=true;
                console.log("36-地球化学异常区段-线");
            }
        });
    };
    var getHddcGeochemicalsvylineController = function(){
        return getServer() + "/hddc/hddcGeochemicalsvylines";
    };
    //37-地球化学探测测线-线
    var addGeochemicalSvyLineData = function(){
        console.log("37-地球化学探测测线-线");
        $.ajax({
            url: getHddcGeochemicalsvylineController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                GeochemicalSvyLineDatas=data;
                displaylayer37=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            GeochemicalSvyLineDataLayer = addLineToMap(LonLatArray, GeochemicalSvyLineDataLayer, 37, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer37=true;
                console.log("37-地球化学探测测线-线");
            }
        });
    };
    var getHddcLavaController = function(){
        return getServer() + "/hddc/hddcLavas";
    };
    //38-熔岩流-面
    var addLavaData = function(){
        console.log("38-熔岩流-面");
        $.ajax({
            url: getHddcLavaController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                LavaDatas=data;
                displaylayer38=false;
                for(var i=0;i<data.length;i++){
                    //var LonLatString = data[i].extends5;//经纬度字符串
                    var LonLatStrings = data[i].extends5;//经纬度字符串
                    if(LonLatStrings==null||LonLatStrings==undefined){
                        continue
                    }
                    var datas=LonLatStrings.split("#");
                    for(var j=0;j<datas.length;j++) {
                        var LonLatString = datas[j];
                        if (LonLatString != null && LonLatString != "") {
                            var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                            var uuid = data[i].uuid;
                            //在地图上添加线
                            LavaDataLayer = addPolygonToMap(LonLatArray, LavaDataLayer, 38, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                        }
                    }
                }
                displaylayer38=true;
                console.log("38-熔岩流-面");
            }
        });
    };

    //选中的图层数据
    var layerSelectType = null;//选中的图层类型
    var layerSelectUuid = null;//选中的图层数据UUID
    var layerSelectBool = false;//是否选中图层数据
    var allshpdatainfos=[];//获取到的所有shp类数据
    var allhpdatainfolines=[];//获取到的所有线对应shp类数据
    var searchshpdatainfos=[];//查询到的初始shp数据
    var displayshpdatainfos=[];//地图展示的shp数据
    var fileshpinfos=[];//地图展示的shp数据
    var loadmaptypes=[];//加载到地图上的数据类型集合

    //在地图上添加线
    var addLineToMap = function(LonLatArray,layer,type,uuid,province,city,area,filename,createuser,createtime){
        if(LonLatArray!=null && LonLatArray.length>0){
            var lnglatArray = [];
            for(var i=0;i<LonLatArray.length;i++){
                var lonlat = LonLatArray[i];
                var lon = lonlat[0];
                var lat = lonlat[1];
                //测试数据
                //lon += Math.random();
                //lat += Math.random();
                var lnglat = new T.LngLat(lon, lat);
                lnglatArray.push(lnglat);
            }
            //创建线对象
            var line = new T.Polyline(lnglatArray);
            //向地图上添加线
            //map.addOverLay(line);
            //添加到图层数组
            //layer.push(line);
            var shpdata=new shpdatainfo(uuid,type,province,city,area,line,filename,createuser,"line",createtime);
            allshpdatainfos.push(shpdata);
            allhpdatainfolines.push(shpdata);
            if(loadmaptypes.indexOf(type)==-1) {
                loadmaptypes.push(type);
            }
            //事件
            //注册线的点击事件
           /* line.addEventListener( "click",function(){
                layerSelectType = type;//选中的图层类型
                layerSelectUuid = uuid;//选中的图层数据UUID
                layerSelectBool = true;//是否选中图层数据
            });
            //注册线的悬浮事件
            line.addEventListener( "mouseover",function(){
                layerSelectType = type;//选中的图层类型
                layerSelectUuid = uuid;//选中的图层数据UUID
                layerSelectBool = true;//是否选中图层数据
            });
            //注册线的悬浮事件
            line.addEventListener( "mouseout",function(){
                //layerSelectType = null;//选中的图层类型
                //layerSelectUuid = null;//选中的图层数据UUID
                layerSelectBool = false;//是否选中图层数据
            });*/
        }

        //layer.hide();
        if(layer!=null && layer.length>0){
            for(var i=0;i<layer.length;i++) {
                var overlay = layer[i];
                overlay.hide();
            }
        }
        return layer;
    };


    /*var addLineToMap = function(LonLatArray,layer,type,uuid,province,city,area,filename,createuser,createtime){
        if(LonLatArray!=null && LonLatArray.length>0){
            var lnglatArray = [];
            for(var i=0;i<LonLatArray.length;i++){
                var lonlat = LonLatArray[i];
                var lon = lonlat[0];
                var lat = lonlat[1];
                //测试数据
                //lon += Math.random();
                //lat += Math.random();
                var lnglat = new T.LngLat(lon, lat);
                lnglatArray.push(lnglat);
            }
            //创建线对象
            var line = new T.Polyline(lnglatArray);
            //向地图上添加线
            map.addOverLay(line);
            //添加到图层数组
            layer.push(line);
            var shpdata=new shpdatainfo(uuid,type,province,city,area,line,filename,createuser,"line",createtime);
            allshpdatainfos.push(shpdata);
            allhpdatainfolines.push(shpdata);
            if(loadmaptypes.indexOf(type)==-1) {
                loadmaptypes.push(type);
            }
            //事件
            //注册线的点击事件
            line.addEventListener( "click",function(){
                layerSelectType = type;//选中的图层类型
                layerSelectUuid = uuid;//选中的图层数据UUID
                layerSelectBool = true;//是否选中图层数据
            });
            //注册线的悬浮事件
            line.addEventListener( "mouseover",function(){
                layerSelectType = type;//选中的图层类型
                layerSelectUuid = uuid;//选中的图层数据UUID
                layerSelectBool = true;//是否选中图层数据
            });
            //注册线的悬浮事件
            line.addEventListener( "mouseout",function(){
                //layerSelectType = null;//选中的图层类型
                //layerSelectUuid = null;//选中的图层数据UUID
                layerSelectBool = false;//是否选中图层数据
            });
        }

        //layer.hide();
        if(layer!=null && layer.length>0){
            for(var i=0;i<layer.length;i++) {
                var overlay = layer[i];
                overlay.hide();
            }
        }
        return layer;
    };*/

    //在地图上添加面
    var addPolygonToMap = function(LonLatArray,layer,type,uuid,province,city,area,filename,createuser,createtime){
        if(LonLatArray!=null && LonLatArray.length>0){
            var lnglatArray = [];
            for(var i=0;i<LonLatArray.length;i++){
                var lonlat = LonLatArray[i];
                var lon = lonlat[0];
                var lat = lonlat[1];
                //测试数据
                //lon += Math.random();
                //lat += Math.random();
                var lnglat = new T.LngLat(lon, lat);
                lnglatArray.push(lnglat);
            }
            //创建面对象
            var polygon = new T.Polygon(lnglatArray,{
                color: "blue", weight: 3, opacity: 0.5, fillColor: "#FFFFFF", fillOpacity: 0.5
            });
            //向地图上添加面
            //map.addOverLay(polygon);
            //添加到图层数组
            //layer.push(polygon);
            var shpdata=new shpdatainfo(uuid,type,province,city,area,polygon,filename,createuser,"polygon",createtime);
            allshpdatainfos.push(shpdata);

            if(loadmaptypes.indexOf(type)==-1) {
                loadmaptypes.push(type);
            }
            //事件
            //注册面的点击事件
            /*polygon.addEventListener( "click",function(){
                layerSelectType = type;//选中的图层类型
                layerSelectUuid = uuid;//选中的图层数据UUID
                layerSelectBool = true;//是否选中图层数据
            });
            //注册面的悬浮事件
            polygon.addEventListener( "mouseover",function(){
                layerSelectType = type;//选中的图层类型
                layerSelectUuid = uuid;//选中的图层数据UUID
                layerSelectBool = true;//是否选中图层数据
            });
            //注册面的悬浮事件
            polygon.addEventListener( "mouseout",function(){
                //layerSelectType = null;//选中的图层类型
                //layerSelectUuid = null;//选中的图层数据UUID
                layerSelectBool = false;//是否选中图层数据
            });*/
        }

        //layer.hide();
        /*if(layer!=null && layer.length>0){
            for(var i=0;i<layer.length;i++) {
                var overlay = layer[i];
                overlay.hide();
            }
        }*/
        return layer;
    };

    //取消右键事件
    document.oncontextmenu = function(){
        return false;
    };

    //添加地图图层的右键菜单
    var addMapMenuToLayer = function(){
        //地图右键菜单项--详细信息事件
        $("#layerContextMenuDiv").unbind("click");
        $("#layerContextMenuDiv").click(function () {
            //隐藏右键菜单
            $("#layerContextMenuDiv").hide();
            //alert(layerSelectType);
            //alert(layerSelectUuid);
            //hddcPointData.showData(1,"02862c0af9344c6b97d9db16761874b7");
            hddcPointData.showData(layerSelectType,layerSelectUuid);
        });

        //地图右键菜单事件
        map.addEventListener("contextmenu",function(e){
            if(layerSelectBool||layerSelectBoolline) {//选中图层
                //distance=1000;
                var lnglat = e.lnglat;
                var p = map.lngLatToContainerPoint(lnglat);
                var left = p.x + "px";
                var top = p.y + "px";
                $("#layerContextMenuDiv").css("left",left);
                $("#layerContextMenuDiv").css("top",top);
                //显示右键菜单
                $("#layerContextMenuDiv").show();
            }else {//未选中图层
                //隐藏右键菜单
                $("#layerContextMenuDiv").hide();
            }
        });

        //地图点击事件
        map.addEventListener("click",function(e){
            //隐藏右键菜单
            $("#layerContextMenuDiv").hide();
        });
    };

    //清空图层
    var clearLayer = function(layer){
        if(layer!=null && layer.length>0){
            for(var i=0;i<layer.length;i++){
                var overlay = layer[i];
                //移除覆盖物
                map.removeOverLay(overlay);
                overlay = null;
            }
        }
        layer = [];

        return layer;
    };

    //显示|隐藏图层
    var showHideLayer = function(layer,bool){
        if(layer!=null && layer.length>0){
            for(var i=0;i<layer.length;i++){
                var overlay = layer[i];
                if(bool){//显示
                    overlay.show();
                }else{//隐藏
                    overlay.hide();
                }
            }
        }
    };

    //根据图层类型和是否勾选参数设置图层显示|隐藏
    var showHideLayerByTypeBool = function(type,bool){
        //地图右键菜单项--详细信息事件
        $("#layerContextMenuDiv").unbind("click");
        $("#layerContextMenuDiv").click(function () {
            //隐藏右键菜单
            $("#layerContextMenuDiv").hide();
            //alert(layerSelectType);
            //alert(layerSelectUuid);
            //hddcPointData.showData(1,"02862c0af9344c6b97d9db16761874b7");
            hddcPointData.showData(layerSelectType,layerSelectUuid);
        });

        //地图右键菜单事件
        map.addEventListener("contextmenu",function(e){
            if(layerSelectBool||layerSelectBoolline) {//选中图层
                //distance=1000;
                var lnglat = e.lnglat;
                var p = map.lngLatToContainerPoint(lnglat);
                var left = p.x + "px";
                var top = p.y + "px";
                $("#layerContextMenuDiv").css("left",left);
                $("#layerContextMenuDiv").css("top",top);
                //显示右键菜单
                $("#layerContextMenuDiv").show();
            }else {//未选中图层
                //隐藏右键菜单
                $("#layerContextMenuDiv").hide();
            }
        });

        //地图点击事件
        map.addEventListener("click",function(e){
            //隐藏右键菜单
            $("#layerContextMenuDiv").hide();
        });
    };

    //清空图层
    var clearLayer = function(layer){
        if(layer!=null && layer.length>0){
            for(var i=0;i<layer.length;i++){
                var overlay = layer[i];
                //移除覆盖物
                map.removeOverLay(overlay);
                overlay = null;
            }
        }
        layer = [];

        return layer;
    };

    //显示|隐藏图层
    var showHideLayer = function(layer,bool){
        if(layer!=null && layer.length>0){
            for(var i=0;i<layer.length;i++){
                var overlay = layer[i];
                if(bool){//显示
                    overlay.show();
                }else{//隐藏
                    overlay.hide();
                }
            }
        }
    };

    //根据图层类型和是否勾选参数设置图层显示|隐藏
    var showHideLayerByTypeBool = function(type,bool){
        layerShowHideBoolArray[type] = bool;//图层是否显示
        if(type==1){//1地质调查规划路线-线图层
            if(bool&&!displaylayer1){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGeologicalSvyPlanningLineData();
                var interval = setInterval(function(){
                    if(displaylayer1){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GeologicalSvyPlanningLineDataLayer,bool);
                    }
                },1000);

            }
            showHideLayer(GeologicalSvyPlanningLineDataLayer,bool);
        }else if(type==2){//2主要活动断层制图区-面
            if(bool&&!displaylayer2){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addMainAFSvyRegionData();
                var interval = setInterval(function(){
                    if(displaylayer2){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(MainAFSvyRegionDataLayer,bool);
                    }
                },1000);

            }
            showHideLayer(MainAFSvyRegionDataLayer,bool);
        }else if(type==3){//3面状资料图层-面
            if(bool&&!displaylayer3){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addMaterialPolygonLayerData();
                var interval = setInterval(function(){
                    if(displaylayer3){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(MaterialPolygonLayerDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(MaterialPolygonLayerDataLayer,bool);
        }else if(type==4){//4目标区-面
            if(bool&&!displaylayer4){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addTargetRegionData();
                var interval = setInterval(function(){
                    if(displaylayer4){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(TargetRegionDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(TargetRegionDataLayer,bool);
        }else if(type==5){//5工作区-面
            if(bool&&!displaylayer5){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addWorkRegionData();
                var interval = setInterval(function(){
                    if(displaylayer5){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(WorkRegionDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(WorkRegionDataLayer,bool);
        }else if(type==6){//6影像索引表-面
            if(bool&&!displaylayer6){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addImageIndexLayerData();
                var interval = setInterval(function(){
                    if(displaylayer6){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(ImageIndexLayerDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(ImageIndexLayerDataLayer,bool);
        }else if(type==7){//7航、卫片解译线-线
            if(bool&&!displaylayer7){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addRSInterpretationLineData();
                var interval = setInterval(function(){
                    if(displaylayer7){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(RSInterpretationLineDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(RSInterpretationLineDataLayer,bool);
        }else if(type==8){//8航、卫片解译面-面
            if(bool&&!displaylayer8){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addRSInterpretationPolygonData();
                var interval = setInterval(function(){
                    if(displaylayer8){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(RSInterpretationPolygonDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(RSInterpretationPolygonDataLayer,bool);
        }else if(type==9){//9航磁-线
            if(bool&&!displaylayer9){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addAviationMagneticData();
                var interval = setInterval(function(){
                    if(displaylayer9){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(AviationMagneticDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(AviationMagneticDataLayer,bool);
        }else if(type==10){//10地壳厚度-线
            if(bool&&!displaylayer10){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addCrustIsolineData();
                var interval = setInterval(function(){
                    if(displaylayer10){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(CrustIsolineDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(CrustIsolineDataLayer,bool);
        }else if(type==11){//11重磁解译线-线
            if(bool&&!displaylayer11){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGMInterpretationLineData();
                var interval = setInterval(function(){
                    if(displaylayer11){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GMInterpretationLineDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(GMInterpretationLineDataLayer,bool);
        }else if(type==12){//12重力场-线
            if(bool&&!displaylayer12){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGravityFieldData();
                var interval = setInterval(function(){
                    if(displaylayer12){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GravityFieldDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(GravityFieldDataLayer,bool);
        }else if(type==13){//13垂直形变-线
            if(bool&&!displaylayer13){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addVerticalDeformationData();
                var interval = setInterval(function(){
                    if(displaylayer13){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(VerticalDeformationDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(VerticalDeformationDataLayer,bool);
        }else if(type==14){//14-1：1万底图岩体线-线
            if(bool&&!displaylayer14){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addRock1LinePreData();
                var interval = setInterval(function(){
                    if(displaylayer14){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(Rock1LinePreDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(Rock1LinePreDataLayer,bool);
        }else if(type==15){//15-1：1万工作底图岩体-面
            if(bool&&!displaylayer15){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addRock1PreData();
                var interval = setInterval(function(){
                    if(displaylayer15){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(Rock1PreDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(Rock1PreDataLayer,bool);
        }else if(type==16){//16-1：25万底图岩体线-线
            if(bool&&!displaylayer16){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addRock25LinePreData();
                var interval = setInterval(function(){
                    if(displaylayer16){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(Rock25LinePreDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(Rock25LinePreDataLayer,bool);
        }else if(type==17){//17-1：25万工作底图岩体-面
            if(bool&&!displaylayer17){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addRock25PreData();
                var interval = setInterval(function(){
                    if(displaylayer17){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(Rock25PreDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(Rock25PreDataLayer,bool);
        }else if(type==18){//18-1：5万底图岩体线-线
            if(bool&&!displaylayer18){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addRock5LinePreData();
                var interval = setInterval(function(){
                    if(displaylayer18){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(Rock5LinePreDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(Rock5LinePreDataLayer,bool);
        }else if(type==19){//19-1：5万工作底图岩体-面
            if(bool&&!displaylayer19){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addRock5PreData();
                var interval = setInterval(function(){
                    if(displaylayer19){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(Rock5PreDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(Rock5PreDataLayer,bool);
        }else if(type==20){//20-1：1万底图地层线-线
            if(bool&&!displaylayer20){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addStratigraphy1LinePreData();
                var interval = setInterval(function(){
                    if(displaylayer20){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(Stratigraphy1LinePreDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(Stratigraphy1LinePreDataLayer,bool);
        }else if(type==21){//21-1：1万工作底图地层-面
            if(bool&&!displaylayer21){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addStratigraphy1PreData();
                var interval = setInterval(function(){
                    if(displaylayer21){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(Stratigraphy1PreDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(Stratigraphy1PreDataLayer,bool);
        }else if(type==22){//22-1：25万底图地层线-线
            if(bool&&!displaylayer22){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addStratigraphy25LinePreData();
                var interval = setInterval(function(){
                    if(displaylayer22){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(Stratigraphy25LinePreDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(Stratigraphy25LinePreDataLayer,bool);
        }else if(type==23){//23-1：25万工作底图地层-面
            if(bool&&!displaylayer23){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addStratigraphy25PreData();
                var interval = setInterval(function(){
                    if(displaylayer23){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(Stratigraphy25PreDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(Stratigraphy25PreDataLayer,bool);
        }else if(type==24){//24-1：5万底图地层线-线
            if(bool&&!displaylayer24){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addStratigraphy5LinePreData();
                var interval = setInterval(function(){
                    if(displaylayer24){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(Stratigraphy5LinePreDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(Stratigraphy5LinePreDataLayer,bool);
        }else if(type==25){//25-1：5万工作底图地层-面
            if(bool&&!displaylayer25){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addStratigraphy5PreData();
                var interval = setInterval(function(){
                    if(displaylayer25){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(Stratigraphy5PreDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(Stratigraphy5PreDataLayer,bool);
        }else if(type==26){//26-活动断层-线
            if(bool&&!displaylayer26){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addActiveFaultData();
                var interval = setInterval(function(){
                    if(displaylayer26){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(ActiveFaultDataLayer,bool);
                    }
                },1000);

                /*setTimeout(function(){
                    var data=ActiveFaultDatas;
                    for(var i=0;i<data.length;i++){
                        //var LonLatString = data[i].extends5;//经纬度字符串
                        var LonLatStrings = data[i].extends5;//经纬度字符串
                        if(LonLatStrings==null||LonLatStrings==undefined){
                            continue
                        }
                        var datas=LonLatStrings.split("#");
                        for(var j=0;j<datas.length;j++) {
                            var LonLatString = datas[j];
                            if (LonLatString != null && LonLatString != "") {
                                var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                                var uuid = data[i].uuid;
                                //在地图上添加线
                                ActiveFaultDataLayer = addLineToMap(LonLatArray, ActiveFaultDataLayer, 26, uuid, data[i].province, data[i].city, data[i].area, data[i].extends8,data[i].createUser,data[i].createTime);
                            }
                        }
                    }
                    displaylayer26=true;
                    loading.close();
                    showHideLayer(ActiveFaultDataLayer,bool);
                    },"1");*/
            }
            showHideLayer(ActiveFaultDataLayer,bool);
        }else if(type==39){
            if(bool&&!displaylayer39){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addActiveFaultpositionerrorData();
                var interval = setInterval(function(){
                    if(displaylayer39){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(ActiveFaultpositionerrorDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(ActiveFaultpositionerrorDataLayer,bool);
        }else if(type==27){//27-地质调查路线-线
            if(bool&&!displaylayer27){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGeologicalSvyLineData();
                var interval = setInterval(function(){
                    if(displaylayer27){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GeologicalSvyLineDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(GeologicalSvyLineDataLayer,bool);
        }else if(type==28){//28-地貌线-线
            if(bool&&!displaylayer28){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGeomorphyLineData();
                var interval = setInterval(function(){
                    if(displaylayer28){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GeomorphyLineDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(GeomorphyLineDataLayer,bool);
        }else if(type==29){//29-地貌面-面
            if(bool&&!displaylayer29){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGeomorphyPolygonData();
                var interval = setInterval(function(){
                    if(displaylayer29){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GeomorphyPolygonDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(GeomorphyPolygonDataLayer,bool);
        }else if(type==30){//30-地质剖面线-线
            if(bool&&!displaylayer30){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGeoProfileLineData();
                var interval = setInterval(function(){
                    if(displaylayer30){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GeoProfileLineDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(GeoProfileLineDataLayer,bool);
        }else if(type==31){//31-微地貌测量线-线
            if(bool&&!displaylayer31){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGeomorphySvyLineData();
                var interval = setInterval(function(){
                    if(displaylayer31){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GeomorphySvyLineDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(GeomorphySvyLineDataLayer,bool);
        }else if(type==32){//32-微地貌测量面-面
            if(bool&&!displaylayer32){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGeomorphySvyRegionData();
                var interval = setInterval(function(){
                    if(displaylayer32){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GeomorphySvyRegionDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(GeomorphySvyRegionDataLayer,bool);
        }else if(type==33){//33-微地貌面测量切线-线
            if(bool&&!displaylayer33){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGeomorphySvyReProfData();
                var interval = setInterval(function(){
                    if(displaylayer33){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GeomorphySvyReProfDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(GeomorphySvyReProfDataLayer,bool);
        }else if(type==34){//34-跨断层钻探剖面-线
            if(bool&&!displaylayer34){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addDrillProfileData();
                var interval = setInterval(function(){
                    if(displaylayer34){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(DrillProfileDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(DrillProfileDataLayer,bool);
        }else if(type==35){//35-地球物理测线-线
            if(bool&&!displaylayer35){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGeophySvyLineData();
                var interval = setInterval(function(){
                    if(displaylayer35){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GeophySvyLineDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(GeophySvyLineDataLayer,bool);
        }else if(type==36){//36-地球化学异常区段-线
            if(bool&&!displaylayer36){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGeochemicalAbnSegmentData();
                var interval = setInterval(function(){
                    if(displaylayer36){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GeochemicalAbnSegmentDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(GeochemicalAbnSegmentDataLayer,bool);
        }else if(type==37){//37-地球化学探测测线-线
            if(bool&&!displaylayer37){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addGeochemicalSvyLineData();
                var interval = setInterval(function(){
                    if(displaylayer37){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(GeochemicalSvyLineDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(GeochemicalSvyLineDataLayer,bool);
        }else if(type==38){//38-熔岩流-面
            if(bool&&!displaylayer38){
                var loading = Loading({
                    text : "正在加载数据，请稍后。"
                });
                loading.show();
                addLavaData();
                var interval = setInterval(function(){
                    if(displaylayer38){
                        loading.close();
                        clearInterval(interval);
                        showHideLayer(LavaDataLayer,bool);
                    }
                },1000);
            }
            showHideLayer(LavaDataLayer,bool);
        }
    };

    //是否显示图层控件
    var layerCheckBoxControlShowBool = false;

    //第一级图层选择控件
    var firstLayerCheckBoxControl = null;

    //添加第一级图层选择控件
    var addFirstLayerCheckBoxControl = function(){
        //第一级图层选择控件
        firstLayerCheckBoxControl = new T.Control({position: T_ANCHOR_TOP_LEFT});
        firstLayerCheckBoxControl.onAdd = function (map) {
            var container = document.createElement("div");
            container.id="spacelayer-layermanger";
            //container.style.backgroundColor = "#fff";
            container.style.cssText = "font-size:16px;border:solid 1px gray;background:#fff;padding:2px;line-height:15px;cursor:pointer;";
            for(var i=0;i<allLayerNameArray.length;i++){
                var id = allLayerNameArray[i][0];//A1_InvestigationRegion
                var value = i;//0
                var text = allLayerNameArray[i][1];//A1_InvestigationRegion(区域调查)
                //添加图层勾选框
                container = addFirstLayerCheckBox(container,id,value,text);
            }

            return container;
        };
        //添加控件
        map.addControl(firstLayerCheckBoxControl);
        firstLayerCheckBoxControl.hide();//隐藏控件
    };

    //第二级图层选择控件
    var secondLayerCheckBoxControl = null;
    //添加第二级图层选择控件
    var addSecondLayerCheckBoxControl = function(index){
        if(secondLayerCheckBoxControl!=null){
            //移除控件
            map.removeControl(secondLayerCheckBoxControl);
            secondLayerCheckBoxControl = null;
        }
        secondLayerCheckBoxControl = new T.Control({position: T_ANCHOR_TOP_LEFT});
        secondLayerCheckBoxControl.onAdd = function (map) {
            var container = document.createElement("div");
            container.className="secondLayerDiv";
            container.id = "secondLayerCheckBoxControl"+index;
            container.style.cssText = "border-radius:5px;font-size:16px;border:solid 1px gray;background:#fff;padding:2px;line-height:15px;cursor:pointer;left:154px;top:90px";
            var id = allLayerNameArray[index][0];//A1_InvestigationRegion
            var name = allLayerNameArray[index][1];//A1_InvestigationRegion(区域调查)
            var layerNameArray = allLayerNameArray[index][2];//第二级图层名称数组
            for(var j=0;j<layerNameArray.length;j++){
                //[1,"地质调查规划路线-线图层","GeologicalSvyPlanningLine"]
                var layerId = layerNameArray[j][2];//GeologicalSvyPlanningLine
                var value = layerNameArray[j][0];//1
                var text = layerNameArray[j][1];//地质调查规划路线-线图层
                var showHideLayerBool = layerShowHideBoolArray[value];//图层是否显示
                //添加图层勾选框
                container = addSecondLayerCheckBox(container,layerId,value,text,showHideLayerBool,index);
            }

            return container;
        };
        //添加控件
        map.addControl(secondLayerCheckBoxControl);

        return secondLayerCheckBoxControl;
    };

    //添加第一级图层勾选框
    var addFirstLayerCheckBox = function(container,id,value,text){
        var checkBox = document.createElement("input");
        //添加勾选框
        container.appendChild(checkBox);
        checkBox.type = "checkbox";
        checkBox.id = id;
        checkBox.value = value;
        //设置选中
        //checkBox.setAttribute("checked","checked");
        checkBox.onmouseover = function(){
            secondLayerCheckBoxControl = addSecondLayerCheckBoxControl(value);
        }
        checkBox.onclick = function(){
            var layerNameArray = allLayerNameArray[value][2];//第二级图层名称数组
            for(var i=0;i<layerNameArray.length;i++){
                var type = layerNameArray[i][0];//1
                var bool = checkBox.checked;
                var checkBoxId = layerNameArray[i][2];//GeologicalSvyPlanningLine
                document.getElementById(checkBoxId).checked = bool;
                //根据图层类型和是否勾选参数设置图层显示|隐藏
                showHideLayerByTypeBool(type,bool);
            }
        }
        //var textNode = document.createTextNode(text);
        var label = document.createElement("LABEL");
        var textNode = document.createTextNode(text);
        label.appendChild(textNode);
        label.onmouseover = function(){
            secondLayerCheckBoxControl = addSecondLayerCheckBoxControl(value);
        }
        //添加文字
        container.appendChild(label);
        //换行
        container.appendChild(document.createElement("br"));

        return container;
    };

    //添加第二级图层勾选框
    var addSecondLayerCheckBox = function(container,id,value,text,checkBoxBool,firstType){
        var checkBox = document.createElement("input");
        //添加勾选框
        container.appendChild(checkBox);
        checkBox.type = "checkbox";
        checkBox.id = id;
        checkBox.value = value;
        checkBox.checked = checkBoxBool;//是否勾选
        //设置选中
        //checkBox.setAttribute("checked","checked");
        checkBox.onclick = function(){
            var bool = checkBox.checked;
            //根据图层类型和是否勾选参数设置图层显示|隐藏
            showHideLayerByTypeBool(value,bool);
            //设置图层是否显示参数
            layerShowHideBoolArray[value] = bool;
            //根据第二级全部图层勾选框状态，设置第一级图层勾选框是否勾选
            setFirstLayerCheckBoxByAllSecondLayer(firstType);
        }
        //添加文字
        container.appendChild(document.createTextNode(text));
        //换行
        container.appendChild(document.createElement("br"));

        return container;
    };

    //根据第二级全部图层勾选框状态，设置第一级图层勾选框是否勾选
    var setFirstLayerCheckBoxByAllSecondLayer = function(firstType){
        var layerNameArray = allLayerNameArray[firstType][2];//第二级图层名称数组
        var showLayerNum = 0;//显示的图层数量
        for(var j=0;j<layerNameArray.length;j++) {
            var secondType = layerNameArray[j][0];//1
            var showHideBool = layerShowHideBoolArray[secondType];
            if(showHideBool){//显示
                showLayerNum++;//数量增加1
            }
        }
        var id = allLayerNameArray[firstType][0];//A1_InvestigationRegion
        if(showLayerNum==0){//全部不显示
            document.getElementById(id).checked = false;
        }else{//全部显示
            document.getElementById(id).checked = true;
        }
    };


    return {
        initMap:initMap,
        initClearMap:initClearMap
    };
});